Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Sending EmailMultiAlternatives in mail_admins()
I have the below view code snippet and I would like to send email as EmailMultiAlternatives to the admins, the problem is...it doesn't render the html tags. Kindly assist with some ideas. subject = "A New Feedback" ctx = { 'name': name, 'email': email, 'message': message } message = ('ecoke/includes/email_feedback.html', ctx) if not settings.ADMINS: return mail_admins(subject, message, fail_silently=True, html_message='text/html') -
Updating wagtail page object and keeping revisions intact
HAs the title says how do I update a wagtail page object, with my own custom fields, and keep the revisions intact? Example problem: I have a Page model as follows: class MyPage(Page): paid = models.BooleanField(default=False) cost = .... .... upgrade_only_field = models.CharField(....) .... User edits these page has a bunch of revisions etcetera. They go through an "Upgrade" view which is a checkout causing them to be able to add / edit additional fields on the model. In the post of this view I am doing: self.object = form.save(commit=False) # Handle updated fields self.object.save() Now unless the object is upgraded a revision is saved that goes under moderator approval. Meaning the revision has submitted_for_moderation = True. I want to clear this on the revisions, since they no longer apply, but in my attempts this causes the previously set fields to be reset by publishing the latest revision. Meaning, after the above I'm doing: latest_revision = self.object.get_latest_revision() if latest_revision and latest_revision.submitted_for_moderation: latest_revision.publish() Am I missing something here? Why does publishing the latest revision (and hence removing moderation) cause this since it's just a ForeignKey to the page object? -
MySQL Host in Django/Nginx/Python setup - reverts to localhost
Odd issue here. This setup used to work in the past on our Django / Nginx / Python setup but is causing issues on a new machine. Very standard settings.py: DATABASES = { 'default': { 'ENGINE':'django.db.backends.mysql', 'NAME': 'dev_database', 'USER': 'dev_user', 'PASSWORD': 'devuser', 'HOST': '123.123.123.123', 'PORT': '3306', } } In the past, not a problem connecting to that HOST (123.123.123.123) however now Django reports that it's attempting to connect to the localhost (let's call that 192.0.0.1): OperationalError: (1045, "Access denied for user 'dev_user'@'192.0.0.1' (using password: YES)") We've flushed settings, wiped out .pyc files, double checked settings. -
Jenkins keeps running slave operations as root
I have a Jenkins Slave node that is used for DJango builds. Part of the procedure involves taking the most recent repository Django code from Git and then building with it. The problem is that when Jenkins runs on the slave machine, it always runs as "root". The problem is similar to this one: Jenkins runs as root instead of Jenkins but not exactly like it. It checks out repositories from Git as root If I do "ls -lart" on the workspace directory, all of the files there are owned by user: root group : root It runs everything as root (on the slave machine) - even though I have configred it to log in as a specific user. See picture of the slave node defined below. In the job (see picture), I am using the slave node only. Why is it doing this? Is some kind of caching going on? If so, how do I remove the cache? I only mention the cache because when one looks at the log file for a Jenkins run, it looks as though it is accessing some kind of cache for "root" [... snip ...] Downloading idna-2.6-py2.py3-none-any.whl (56kB) Collecting decorator (from ratelim->geocoder==1.33.0->-r requirements.txt … -
Listing tags by ManyToMany relationship in django
I'm learning Django and have gone already through various tutorials. I have created a basic blog site, but wanted to add tagging funcionality. It works - I have posts with assigned tags, but I'm struggling to list those tags in the post now. blog/models.py: class Post(models.Model): title = models.CharField(max_length=50) text = models.CharField(max_length=1000) pub_date = models.DateTimeField('date published') author = models.CharField(max_length=30) mail = models.EmailField() class Tag(models.Model): name = models.CharField(max_length=15) posts = models.ManyToManyField(Post, related_name="tags") I know I would need something like: Tag.objects.filter() but could you please guide me how to list only those related to the specific post? I was trying various combinations, but none of them worked really well... -
creating forms in django - error in output
I have the following code in various places to attempt to produce a form in Django that takes data and writes it to the database views.py from django.shortcuts import render from django.http import HttpResponse from django.http import HttpResponseRedirect from .forms import TeacherSignup """def teachers(request): return render(request,'teachers/teachers.html') """ def teachers(request): # if this is a POST request we need to process the form data if request.method == 'POST': # create a form instance and populate it with data from the request: form = TeacherSignup(request.POST) # check whether it's valid: if form.is_valid(): # process the data in form.cleaned_data as required # ... # redirect to a new URL: return HttpResponseRedirect('/thanks/') # if a GET (or any other method) we'll create a blank form else: form = TeacherSignup() return render(request, 'teachers/teachers.html', {'form': form}) teachers.html (this is the html page that contains the form) <form action="/teachers/" method="post" style="border:1px solid #ccc"> {% csrf_token %} {{ form }} <div class="container"> <label><b>Email</b></label> <input id="email" input type="text" placeholder="Enter Email" name="email" required> <label><b>Centre/School Name</b></label> <input id="school_name" input type="text" placeholder="Enter School or Centre Name" name="school_name" required> <label><b>Password</b></label> <input id="password" input type="password" placeholder="Enter Password" name="password" required> <label><b>Repeat Password</b></label> <input id="password_repeat" input type="password" placeholder="Repeat Password" name="password_repeat" required> <input type="checkbox" checked="checked"> Remember me … -
TypeError: cannot make memory view because object does not have the buffer - django
I am trying to make a post request to mailchimp's api. It works perfectly fine when I am doing it in my local machine but somehow when I push it into the cloud. This error appears and I thought it was because of the python version since it's the only differences between local and the cloud. In cloud it's python 2.7.6 local I am using 2.7.12 I have searched up but a few issues only talks about other lib that's causing the error. I didn't have new requirements installed at all. I can calling a post request by using something like requests.post(MAILCHAMP_API, payload, headers=headers).json() Then I get an error of cannot make memory view because object does not have the buffer interface Exception Location: /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/contrib/pyopenssl.py in sendall, line 216 -
send_email() takes 1 positional argument but 3 were given - Django Python
I am trying to send a test email from my Django python project and following the django docs for that. When the below function is executed I get an error (image attached). What I am doing wrong? https://docs.djangoproject.com/en/2.0/topics/email/ from django.core.mail import send_mail, BadHeaderError from django.http import HttpResponse, HttpResponseRedirect def send_email(request): subject = request.POST.get('subject', 'Test') message = request.POST.get('message', 'Test Message') from_email = request.POST.get('from_email', 'test@example.com') if subject and message and from_email: try: send_mail(subject, message, from_email, ['admin@example.com']) except BadHeaderError: return HttpResponse('Invalid header found.') return HttpResponseRedirect('/contact/thanks/') else: # In reality we'd use a form class # to get proper validation errors. return HttpResponse('Make sure all fields are entered and valid.') Error: -
Is it possible to use django generic-class based view with a database view as model?
This is my problem, i'm building a kind of clown of stackoverflow, i have questions, tags, category as models, in the welcome page of the site, i should list all the questions, i've done it using class based views on Question Model but, i don't have all the details i want. So i've created a view in my DB and a model corresponding to it. I've tried to use class based view in other to display questions list but based on that view. But i always obtain an empty list even if the view has data. -
Django error on running server and making migrations:
I get the following error on running my server, following making migrations and migrating: ERROR Warnings: ?:(urls.W005) URL namespace 'admin' isn't unique. You may not be able to reverse all URLs in this namespace. Is anyone able to explain the above error and also suggest ways of resolving it? -
How to implement a lesson timetable with multiple preset period times?
I want to implement a school timetable. Currently my ideas is to have a model for teachers, rooms, subjects, periods, and all of those are foreign keys of a lesson. The problem is I want to have multiple time values for periods. For example, on holidays all periods are 15 minutes shorter. Of course it would be nice if these preset time values would be a model (maybe called Times) with something like an array of pairs of start and end times. Being a model, the objects could be easily edited or created in the website. So for example one such object could be represented as ((9:00, 9:45), (10:00, 10:45), (11:00, 11:45)) and times for days with shortened lessons could be represented as ((9:00, 9:30), (9:40, 10:10), (10:20, 10:50)). As of now I have the following models: DAY_OF_THE_WEEK = ( ('1', 'Monday'), ('2', 'Tuesday'), ('3', 'Wednesday'), ) class Period(Model): weekday = models.CharField(max_length=2, choices=DAY_OF_THE_WEEK) begin_time = models.TimeField() end_time = models.TimeField() class Lesson(Model): period = models.ForeignKey(Period, on_delete=models.CASCADE) subject = ... person = ... Currently I'd have to (preferably atomically) change all the begin_ and end_times in all Periods. It would be nicer if Period was just the weekday field and an index … -
python manage.py migrate Django Error
I was following the django documentation https://docs.djangoproject.com/en/2.0/topics/migrations/ when i try to run python manage.py migrate I always get a traceback error. I even do python manage.py makemigrations and I still get this traceback error Here -
Django CSRF verfication failed
I am new to Django and I have a problem with CSRF verification. I have so far created Django POST forms that are successful and have no CSRF errors. But when I try to create the following form, I get CSRF verification failure: "CSRF token missing or incorrect". {% for a in answers %} {% csrf_token %} <form class="" action="." method="post"> <input type="submit" value="{{ a.answer }}" name={{a.answer_id}}></input> </form> <p>Number of votes: {{ a.votes }}</p> {% empty %} <p>There are no answers for the poll</p> {% endfor %} Here is what the models look like: class Question(models.Model): date_added = models.DateTimeField(auto_now_add=True) question = models.CharField(max_length=200) number_of_answers = models.IntegerField(default=0) class Answer(models.Model): question = models.ForeignKey(Question) answer = models.CharField(max_length=200) votes = models.IntegerField(default=0) Here is what the view function for that form looks like (so far I haven't added any code to process the post request): def poll(request, question_id): if request.method == "POST": pass poll = Question.objects.get(id=question_id) answers = poll.answer_set.order_by() context = {'poll' : poll, 'answers' : answers} return render(request, 'polls/poll.html', context) Basically, for each question there are multiple answers. I want to allow the user to click the button associated to a particular answer. Once the user clicks a button, I want to increase the vote … -
Django admin panel display error linked to admin.py?
I have a seemingly harmless but very niggling error in my admin panel: It erroneously produces the output "Teacherss" (double ss) and I cannot see why this occurs from my code: So the models.py in the teachers app is: class Teachers(models.Model): #this is what an album is going to be made of email=models.CharField(max_length=250) school_name=models.CharField(max_length=500) password=models.CharField(max_length=100) class_name=models.CharField(max_length=100) The admin.py file has this: from django.contrib import admin from main.models import Teachers # Register your models here. admin.site.register(Teachers) Any idea why this is generated in the admin panel? MAIN Teacherss Add/Change Where is the double ss coming from and how do I get rid of it!?? -
Passing an object to serializer gives 'serializer: Unable to get repr for <class 'MyModel.serializers.MyModelSerializer'>
I'm getting this error in debugger but the actual response I get from this endpoint is correct. When I pass an existing object from DB to serializer i get this error (shown below in code sample). This is a create API view that gets POST data then checks if that object exists in DB. If it does exist then returns that object, otherwise proceeds to create it. class CreateMyModel(generics.ListCreateAPIView): serializer_class = MyModelSerializer queryset = MyModel.objects.all() permission_classes = (IsAuthenticated,) authentication_classes = (JSONWebTokenAuthentication,) def post(self, request, *args, **kwargs): try: obj = Obrazac.objects.get(uuid=request.data.get('uuid')) serializer = self.get_serializer(obj) <-- *serializer: Unable to get repr for <class 'MyModel.serializers.MyModelSerializer'>* return Response(serializer.data, status=status.HTTP_200_OK) except ObjectDoesNotExist: return self.create(request, *args, **kwargs) class MyModel(models.Model): field1 = models.TextField() field2 = models.ForeignKey(SomeOtherModel) def __str__: return str(self.uuid) -
django search box in navigation box to search postgresql
I want to put a search box in the base.html navigation bar that searches one table in my postgreSQL and produces a drop-down of matching names that then goes straight to the selected detail. So I know I need a form tag in base.html, and a url pattern and a CBV. Thanks in advance. -
Django override UserManager to use custom user model
I'm stuck trying to override UserManager to point to my custom user model so I can implement a user registration form. I keep getting the error message: Manager isn't available; 'auth.User' has been swapped for 'users.CustomUser' So I know the manager isn't pointing to CustomUser but instead to the default User model, but I can't figure out how to change this. My settings.py: AUTH_USER_MODEL = 'users.CustomUser' Within my users app here is forms.py: from django.contrib.auth.forms import UserCreationForm from .models import CustomUser class CustomUserCreationForm(UserCreationForm): class Meta(UserCreationForm.Meta): model = CustomUser fields = UserCreationForm.Meta.fields And here is my models.py file: from django.contrib.auth.models import AbstractUser from django.db import models class CustomUser(AbstractUser): pass class CustomUserManager(UserManager): pass How do I set CustomUserManager to point to my CustomUser model and then where do I point my code to CustomUserManager? Thanks for any help. -
Given a django assignment I'm struggling with
Basically, I'm supposed to have a login/reg page with validations (which is complete and working great.) Then have it redirect to a landing page that displays all the other users (not including the logged in user) on a table. Then it lists out all their information (see picture) with a button that allows you to poke other people and how many times they've been poked. There is also a list of people who have poked you and how many times they poked you. I really need help. How do you display the logged in users name at the top in jinja? Something like {{ user.alias }} which I can't get to work. User is the table name and alias is the field name in the db. How do you display all the records on the table? How do you display the poke history on the table? How do you add the list of people who've poked you and order it by descending order? I'm really at a loss on how to accomplish this. Any and all help would be appreciated. Am I supposed to create another table to track the pokes. I'd be willing to pay for a good answer … -
What does adding on_delete to models.py do, and what should I put in it?
FYI, the on_delete parameter in models is backwards from what it sounds like. You put "on_delete" on a Foreign Key (FK) on a model to tell django what to do if the FK entry that you are pointing to on your record is deleted. The options our shop have used the most are PROTECT, CASCADE, and SET_NULL. Here are the basic rules I have figured out: Use PROTECT when your FK is pointing to a look-up table that really shouldn't be changing and that certainly should not cause your table to change. If anyone tries to delete an entry on that look-up table, PROTECT prevents them from deleting it if it is tied to any records. It also prevents django from deleting your record just because it deleted an entry on a look-up table. This last part is critical. If someone were to delete the gender "Female" from my Gender table, I CERTAINLY would NOT want that to instantly delete any and all people I had in my Person table who had that gender. Use CASCADE when your FK is pointing to a "parent" record. So, if a Person can have many PersonEthnicity entries (he/she can be American Indian, Black, … -
Migration failing when pushing to Cloud foundry
When I do make migrations on my local computer its working fine and completes without any error but when I push my code to cloud Foundry it is ending in error. Log: 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] OUT Operations to perform: 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] OUT Apply all migrations: admin, auth, commonpage, contenttypes, sessions, taskmaster 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] OUT Running migrations: 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR Traceback (most recent call last): 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR File "manage.py", line 22, in 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR execute_from_command_line(sys.argv) 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR File "/home/vcap/deps/0/python/lib/python3.5/site-packages/django/core/management/init.py", line 363, in execute_from_command_line 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR utility.execute() 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR File "/home/vcap/deps/0/python/lib/python3.5/site-packages/django/core/management/init.py", line 355, in execute 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR self.fetch_command(subcommand).run_from_argv(self.argv) 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR File "/home/vcap/deps/0/python/lib/python3.5/site-packages/django/core/management/base.py", line 283, in run_from_argv 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR self.execute(*args, **cmd_options) 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR File "/home/vcap/deps/0/python/lib/python3.5/site-packages/django/core/management/base.py", line 330, in execute 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR output = self.handle(*args, **options) 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR File "/home/vcap/deps/0/python/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 204, in handle 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR fake_initial=fake_initial, 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR File "/home/vcap/deps/0/python/lib/python3.5/site-packages/django/db/migrations/executor.py", line 115, in migrate 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR File "/home/vcap/deps/0/python/lib/python3.5/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR File "/home/vcap/deps/0/python/lib/python3.5/site-packages/django/db/migrations/executor.py", line 244, in apply_migration 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR state = migration.apply(state, schema_editor) 2017-12-21T02:03:34.85+0530 [APP/PROC/WEB/0] ERR … -
Django app on Heroku: can't open new browser window via webbrowser call
I have a django app on heroku that requires user authorization via the spotify web API. I am using the python webbrowser module to send the user to the authorization link. Everything works locally. To run on Heroku I have installed RQ, and am using the Redis To Go add-on, and have added workers to run the webbrowser call. Procfile: web: gunicorn app.wsgi --log-file worker: python app/worker.py When I look at the heroku logs I see that my worker is running and is executing the webbrowser call, however, a browser window doesn't pop up and my heroku app ends up timing out. Heroku log: 2017-12-20T07:27:19.057800+00:00 heroku[router]: at=info method=GET path="/" host=myapp.herokuapp.com request_id=e5212374-7a1a-4058-be2d- eb455018fed4 fwd="76.29.43.60" dyno=web.1 connect=0ms service=4ms status=200 bytes=1610 protocol=https 2017-12-20T07:27:19.129041+00:00 heroku[router]: at=info method=GET path="/static/app/indexcss2.css" host=myapp.herokuapp.com request_id=365c8ff9-e0a6-4713-91c0-8d32906201b8 fwd="76.29.43.60" dyno=web.1 connect=0ms service=3ms status=304 bytes=144 protocol=https 2017-12-20T04:37:24.436886+00:00 app[worker.1]: 04:37:24 default: app.auth.goToSpotify('https://accounts.spotify.com/authorize? client_id=clientid&response_type=code&redirect_uri=redirecturi') (49322ff7- e8b6-45a3-9eca-a26ea6e238ca) 2017-12-20T04:37:24.467101+00:00 app[worker.1]: 04:37:24 default: Job OK (49322ff7-e8b6-45a3-9eca-a26ea6e238ca) 2017-12-20T04:37:24.467238+00:00 app[worker.1]: 04:37:24 Result is kept for 500 seconds 2017-12-20T04:37:24.475089+00:00 app[worker.1]: 04:37:24 2017-12-20T04:37:24.475195+00:00 app[worker.1]: 04:37:24 *** Listening on high, default, low... 2017-12-20T04:37:54.068516+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/submit/" host=myapp.herokuapp.com request_id=3161d8be-6302-41ae-8b3a-2b28ebd2420c fwd="209.249.175.76" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https My app.goToSpotify function: import webbrowser def goToSpotify(auth_url): webbrowser.open(auth_url, new=1) return 1 Does anybody know … -
ValueError: Cannot assign must be an instance
I have the following pre-existing database table which contains and id and a description. I have to load this prior to my User table in order to associate the ForeignKey correctly. class QVDSSSecurityDimension(models.Model): coid = models.CharField(db_column='CM_Data_Restriction', serialize=False, max_length=10, primary_key = True) # Field name made lowercase. coid_name = models.CharField(db_column='CM_Company_Name', max_length=50, blank=True, null=True) # Field name made lowercase. class Meta: managed = False db_table = 'QV_DSS_Security_Dimension' My custom user model is built on the following: class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField(unique=True) username = models.CharField(max_length=7, unique=True) formattedusername = models.CharField(max_length=11, unique=True, primary_key = True) first_name = models.CharField(max_length=40) last_name = models.CharField(max_length=140) date_joined = models.DateTimeField(default=timezone.now) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) is_cfo = models.BooleanField(default=False) facility = models.CharField(max_length=140) officename = models.CharField(max_length=100) jobdescription = models.CharField(max_length=140) positioncode = models.CharField(max_length = 100) positiondescription = models.CharField(max_length=140) coid = models.ForeignKey(QVDSSSecurityDimension, null=True, blank = True, db_constraint=False) streetaddress = models.CharField(max_length=140) title = models.CharField(max_length=100) USERNAME_FIELD = 'username' class Meta: app_label = 'accounts' db_table = "user" def save(self, *args, **kwargs): self.formattedusername = '{domain}\{username}'.format( domain='HCA', username=self.username) super(User, self).save(*args, **kwargs); def get_short_name(self): return self.username # REQUIRED_FIELDS = "username" def __str__(self): return '%s - %s %s' % (self.username, self.first_name, self.last_name) Everything works with the makemigrations and migrate, but if a User.coid doesn't exist in the database I get … -
How should I use Factory_boy in Django to create test data?
Python 3.6.3 Django 1.11.4 My structure is something like: myproject guys | models.py | factory.py models.py looks like: from django.db import models class Guy(model.Model): first_name = models.CharField(max_length=35) last_name = models.CharField(max_length=35) my factories.py looks like import factory import django from guys import models class GuyFactory(factory.Factory): class Meta: model = models.Guy first_name = factory.Faker('first_name') last_name = factory.Faker('last_name') django.setup() for i in range(1, 100): GuyFactory.create() But if I run this from the command line I get python3 authors/factories.py Traceback (most recent call last): File "guys/factories.py", line 5, in from guys import models ModuleNotFoundError: No module named 'guys' I'm not even sure if this is the right way to execute this script. I've been developing inside PyCharm. When I run the script inside PyCharm I get "django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet." -
Simplest Way to Run Matlab Script with Django
I would like to integrate a MATLAB script into a website I built with Django. The script accepts a few parameters and returns a table to the user. I am a novice Django user. I would like to know the simplest and fastest way to execute my MATLAB script using Django and return the results to the user. From what I have read online, it appears there are a few options: 1.) execute script using octave (free so I wouldn't need to pay for MATLAB license for the server) 2.) compile my MATLAB function as python library, write a python script with MATLAB function, and execute the script server-side using django and 3.) compile the MATLAB function as a standalone application and run that application on the server (unclear to me how exactly this would work). There are probably more options I am missing and I would appreciate recommendations on the simplest way to run a MATLAB script on a Django site. Also, the script is fast to execute and takes a 5< seconds to run on my computer, so I think I would not need to use a distributed task queue system like Celery. -
Django site creating a link from html page to another app's main html page
I have an index page in a django project that has (in it's header.html page) a navigation bar. I want the navigation bar to actually work ...currently when I click on 'teachers' in the nav bar I get an error. The code in header.html (which has the nav bar) </button> <div class="collapse navbar-collapse" id="navbarResponsive"> <ul class="navbar-nav ml-auto"> <li class="nav-item mx-0 mx-lg-1"> <a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="/teachers/teachers.html">Teachers</a> </li> </div> The link above in question is: href="/teachers/teachers.html">Teachers The file path/structure of where the teachers.html page is: C:\Users\User\Desktop\rast\teachers\templates\teachers The error: Using the URLconf defined in website.urls, Django tried these URL patterns, in this order: admin/ admin/ header/ [name='header'] [name='index'] teachers/ The current path, teachers.html, didn't match any of these. My question is - what do I need to write in the header.html page (or do I need to dos something else?) to get the nav bar button 'teachers' to go to the teachers.html page.