Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to graph a matplot linear function in Django?
I am creating a small web with Django and I am looking to graph a linear function with machine learning in it using matplotlib. When I make the code in Spyder the graphic looks like this here However, when using Django and wanting to embed the graph, an error occurs, although this does not happen if I remove a few lines of code. This is the first part of the code: def plot(request): plt.rcParams['figure.figsize'] = (9, 6) plt.style.use('ggplot') data = pd.read_csv("datos.csv") filtered_data = data[(data['Fecha'] <= 30) & (data['Oxxos'] <= 50000)] colores=['orange','blue'] tamanios=[30,60] f1 = filtered_data['Fecha'].values f2 = filtered_data['Oxxos'].values f = plt.figure() asignar=[] for index, row in filtered_data.iterrows(): if(row['Fecha']>7): asignar.append(colores[0]) else: asignar.append(colores[1]) plt.scatter(f1, f2, c=asignar, s=tamanios[0]) dataX =filtered_data[["Fecha"]] X_train = np.array(dataX) y_train = filtered_data['Oxxos'].values regr = linear_model.LinearRegression() regr.fit(X_train, y_train) y_pred = regr.predict(X_train) ## HERE IS WHERE THE CODE BELOW WOULD GO ## buf = io.BytesIO() canvas = FigureCanvasAgg(f) canvas.print_png(buf) response = HttpResponse(buf.getvalue(), content_type='image/png') f.clear() response['Content-Length'] = str(len(response.content)) return response Until then, the graphic looks something like this here. The code that causes problems is the one that goes between the y_pred = regr.predict (X_train) and the buf = io.BytesIO (). The code that goes between these two lines is responsible for … -
Best and fastest method to add only unique records based on certain fields in Django
I have a model with multiple fields where data is text type for the most part. I want to put a validation that from now on if a new record is being added, it should be unique based on 3 fields. Here one of the fields is a one-to-many field as is in another table. I can try fetching all the records and start checking them using for-loop. I tried using annotate but it seems to help if the record is already in the table, but I want to do this validation before adding. I need a fast method for this validation. class Product(models.Model): brand = models.TextField(default='{}', null=True) sub_brand = models.CharField(null=True) . . . class ProductNetWeight(models.Model): product = models.ForeignKey(Product, on_delete=models.CASCADE, related_name='product_net_weight') net_weight = models.CharField(null=True) -
No effect on global variable
I have a problem with my code. I am creating a small web application, and I want to retrieve a value that has been entered on an html page. Therefore I use the forms. I am recovering my value in message. I imported another python file "thread.py" which contains a reception() function to assign it to a global variable "var_maman" initialized at the beginning to 0. When I run the DJango application and then run my thread.py program (it continuously displays the global variable) and I enter a value on my site, there is no change on the global variable, I don't know what to do anymore. Thank you for your help! view.py from __future__ import unicode_literals from django.shortcuts import render,redirect from django.http import HttpResponse, Http404 import sql import thread from .forms import ContactForm # Create your views here. def RPI(request,rpi_id): if int(rpi_id) > 10: return redirect("/page/accueil/") Pactive = sql.run("Pactive") Preactive = sql.run("Qreactive") Courant = sql.run("I") form = ContactForm(request.POST or None) if form.is_valid(): message = form.cleaned_data['message'] thread.reception(message) print("Le message est : RPI"+rpi_id+","+message) envoi = True return render(request, 'page/RPI.html',locals()) thread.py import sys import time global var_maman def reception(message): global var_maman print("entre dans reception") var_maman = message if __name__ == '__main__': global … -
Filter models on the basis of dictionary key
I am facing a problem while filtering a record from the database. In my database I have records which contain a dictfield. for eg region is a dictionary which contains other dictionaries like region = {'eastus': {'percentage_change': 0}, 'westus': {'percentage_change': 0}} and I want to fetch eastus or westus. I have tried something like this, but I am getting an empty list. MyModel.objects.filter(region__eq='eastus') any suggestions for this problem? -
Django 2.0: How can I get the upload time/duration of a submitted form (with files)?
I have some forms with file fields. I need to know how long it takes to upload the files once I submit the form. I don't need the time for every file, just for the whole form. I'm thinking of getting the upload start and end times, then get the difference between the two. Problem is, I don't know where I should exactly put them. I thought of putting it somewhere at the beginning of the related view functions, but in my tests, they run after the files have been uploaded. I'm also looking at writing a custom Upload Handler (https://docs.djangoproject.com/en/2.2/ref/files/uploads/), but not sure at how to start with it. Since there are only a few forms where I need to get the upload times, I'd prefer to not use any library for this unless it's very necessary. -
Django: How to display specific object to specific user
I am new to django and working on a project where admin have to assign a team to manager and when ever admin assign a team to manager then it will be shown to that specific manager only.I have no idea how can i do this. Please if someone can help please help me. here is my .html file for admin from where admin can assign team to manager. <thead> <tr> <th>S No.</th> <th>COMPANY NAME</th> <th>TEAM MEMBER</th> <th>EMAIL</th> <th>ASSIGN TEAM</th> </tr> </thead> <tbody> {%for team in object%} <tr> <form id="form_id" method="POST" action = "{% url 'accept' %}"> {% csrf_token %} <th scope="row"> {{ forloop.counter }}</th> <td>{{team.company_name}}</td> <td>{{team.team_member}}</td> <td>{{team.email}}</td> <td> <select name="manager_{{manager.id}}"> {% for manager in managers %} <option value ="{{manager.id}}">{{manager.name}}</option> {% endfor %} </select> </td> <td> <input class="btn btn-raised btn-primary btn-round waves-effect" type="submit" value="Assign"> </td> </tr> {% endfor %} here is my model for the team and manager: class Team(models.Model): first_name = models.CharField(max_length= 50) last_name = models.CharField(max_length= 50) company_name = models.CharField(max_length= 100) address = models.CharField(max_length= 1000) state = models.CharField(max_length= 100) city = models.CharField(max_length= 100) status = models.CharField(max_length= 30) class manager(models.Model): name = models.CharField(max_length= 500) designation = models.CharField(max_length= 500) here is my views.py file for manager and from where the admin … -
django - Changes in template files are not shown
i'm working on a django project, after changing some templates, it works on my local machine but after uploading to production server(+restarting apache) webserver shows the old code! and its about few specific base template files. tried to restart server + reload webserver + reinstall venv.. None worked. do i use template/fragment caching? no do i use apache's caching? no -
Update new field for all users upon migration
I learned Django recently. Now on one of the projects I'm working on, I need to add a new field, is_core_administrator to model UserProfile, which will set the oldest user as a core administrator. I need to update this field for all users with migration. Is there a way to do this? I mean, when I make migrations, is it possible to update this field to true for the oldest user, and false for rest. Finding the oldest user will not be difficult since we already have another field DateJoined. I just want to update the corresponding field on making the migration. -
is there any way to modify the current logging to json format with few other fields added python logging
I have many application code written in python django and every application is using standard python logger module and just a simple message strings are getting logged. Now is there any way where I can add my own customer middleware or django app where when ever the logging is called in their methods it should reach my function and I will add more value to the logs, make a proper json format and then write to the log file. So that in current application developer don't need to do lots of changes except that he need to add my django app or a middle ware -
Design pattern(s) for models based on location and variety of it's properties (child models)?
I'm facing a "writers block" and cannot figure out how to proceed. Everything seems to relate to each other and cannot choose which path to follow. Currently I'm trying to figure out that how should I model entities that are based on location (map) and different properties such as animals on area, possible access restrictions to area on certain dates etc. My current setup has models for Area, Map, Species and Resctrictions. However, I'm not certain that should I separate Map from Area? Or how should I model different Restrcitions types for different such as dates, amounts, allowed vehicles etc.? Do I need BaseResctriction which is inherited by DateResctriction, VehicleRestricion and having some common fields for all restrictions? -
Serializer Error When Using Rest Framework to Serialize Nested Objects from Model
I have seen some related posts, but I am not sure what I need to do. I have set up a view to serialize my test model which has nested models. I have set up the serializers, but I get the error "Got AttributeError when attempting to get a value for field Question on serializer TestSerializer.\nThe serializer field might be named incorrectly". My Serializers: class AnswerSerializer(serializers.ModelSerializer): class Meta: model = Answer fields = ('id', 'number', 'text', 'iscorrect') class QuestionSerializer(serializers.ModelSerializer): answer = AnswerSerializer() class Meta: model = Question fields = ('id', 'number', 'text', 'answer') related_object = 'answer' class TestSerializer(serializers.ModelSerializer): question = QuestionSerializer() class Meta: model = Test fields = ('id', 'name', 'question') related_object = 'question' My Models: class Test(models.Model): user = models.ForeignKey(User, on_delete=models.PROTECT) name = models.CharField(max_length=255,default='',blank=False) datecreated = models.DateTimeField(auto_now=True) def __str__(self): return self.name class Question(models.Model): test = models.ForeignKey(Test, on_delete=models.CASCADE) text = models.CharField(max_length=255,default='',blank=False) number = models.IntegerField() def __str__(self): return self.text class Answer(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) text = models.CharField(max_length=255,default='',blank=False) number = models.IntegerField() iscorrect = models.BooleanField(default=False) def __str__(self): return self.text The call from the view: serializer = TestSerializer(test, many=True) -
How to embed a linear function with matplotlib in django?
I am developing a Java web application with jsp, servlets, etc. and I need to connect it with a Django html page which will show a linear function for a predictive model. I tried with an example that I found here: https://github.com/hcosta/django-matplotlib-example/blob/master/core/views.py That model works perfectly, however, when I try to show the graph of my linear function something does not work, as you can see here: https://imgur.com/a/dwwIsQ1 Code of the linear function def plot(request): f = plt.figure() plt.rcParams['figure.figsize'] = (9, 6) plt.style.use('ggplot') data = pd.read_csv("datos.csv") print(data.shape) print(data.head()) print(data.describe()) filtered_data = data[(data['Fecha'] <= 30) & (data['Oxxos'] <= 50000)] colores=['orange','blue'] tamanios=[30,60] f1 = filtered_data['Fecha'].values f2 = filtered_data['Oxxos'].values asignar=[] for index, row in filtered_data.iterrows(): if(row['Fecha']>7): asignar.append(colores[0]) else: asignar.append(colores[1]) plt.scatter(f1, f2, c=asignar, s=tamanios[0]) dataX =filtered_data[["Fecha"]] X_train = np.array(dataX) y_train = filtered_data['Oxxos'].values regr = linear_model.LinearRegression() regr.fit(X_train, y_train) y_pred = regr.predict(X_train) def f(x): return regr.coef_*x+2420 x = range(0, 30) plt.plot(x, [f(i) for i in x]) plt.axhline(0, color="black") plt.axvline(0, color="black") plt.xlim(0, 15) plt.ylim(0, 20000) buf = io.BytesIO() canvas = FigureCanvasAgg(f) canvas.print_png(buf) response = HttpResponse(buf.getvalue(), content_type='image/png') f.clear() response['Content-Length'] = str(len(response.content)) return response I hope that the linear function is shown, instead of the icon as if the image of it did not exist. -
Redirecting admin site custom button to views
I have created a custom button in django admin .I want to redirect it to my views. {% extends "admin/change_form.html" %} {% load i18n %} {% block submit_buttons_bottom %} {{ block.super }} <div class=”submit-row list-group”> <button type=”button” title=”download file” class=”list-group-item active” name=”download_file”;”> <span class=”glyphicon step-backward”></span> <span class=”text”>Download file</span> </button> </div> {% endblock %} In this code the button works like save button and saves the data to my model but instead of saving it I want to redirect it to views and access the data in views.Is there anyway I could do this?Any help would be appreciated. -
How to change the output UI of fieldboolean to make it visually in exact location
in Model.py is_active = models.BooleanField(default=False) in adminx.py Fieldset(PrependedText('is_active',': '),),) output https://imgur.com/a/5nfaDlY as you can see the checkbox(boolean) is a bit outlined to the left how to change the location to a bit right which makes it look better? -
nonetype' object has no attribute 'startswith'
I have follwing models: class Fulfillment(TenantModel): id = models.BigIntegerField(primary_key=True) shipment = TenantForeignKey('Shipment', on_delete=models.CASCADE) product_instance = TenantForeignKey(ProductInstance, on_delete=models.CASCADE) class ProductInstance(TenantModel): id = models.BigIntegerField(primary_key=True) product = TenantForeignKey(Product, on_delete=models.CASCADE) class Product(TenantModel): id = models.BigIntegerField(primary_key=True) product_type = models.CharField(max_length=32) I want to filter all the shipment which product type is not equal to 'subscription'. When i am doing this Shipment.objects.filter(Q(fulfillment__product_instance__product__product_type='subscription')) I am getting correct result. When i am doing this Shipment.objects.filter(~Q(fulfillment__product_instance__product__product_type='subscription')) i am getting AttributeError: 'NoneType' object has no attribute 'startswith' -
how to use django forloop to change the design by each row?
here i want to display foods in first row with design of {% else %} part and second row in the design of {% if %} part and so on.I tried this but it is not working as i wanted.How can i use forloop for this in template ? template <div class="iso-item" data-aos="zoom-in-up" data-aos-duration="1000"> {% for category in menu_categories %} {% for food in category.food_set.all %} {% if forloop.counter|divisibleby:2 %} <div class="item {{category.id}}"> <!-- Iso-Item .// --> <!-- Alternate .// --> <div class="menu-card-main"> <div class="menu-card-image"> <a href="img/dish/menu3.jpg" data-lightbox="menu3" data-title="{{food.name}}"><img src="/media/{{food.image}}" alt="Dish3"></a> </div> <div class="manu-card-content main-box"> <p class="dish-price text-center u-margin-bottom-mini">{{food.price}}</p> <h4 class="dish-name text-center u-margin-bottom-small">{{food.name}}</h4> <p class="dish-detail text-center">{{food.detail}}</p> </div> </div> </div> <!-- Iso-Item .// --> <!-- Alternate .// --> {% else %} <div class="item {{category.id}}"> <!-- Iso-Item .// --> <div class="menu-card-main "> <div class="manu-card-content main-box{% if food.featured %}menu-card-image recommend{% endif %}"> <br> <p class="dish-price text-center u-margin-bottom-mini">{{food.price}}</p> <h4 class="dish-name text-center u-margin-bottom-small">{{food.name}}</h4> <p class="dish-detail text-center">{{food.detail}}</p> </div> <div class="menu-card-image"> <a href="#" data-lightbox="menu1" data-title="{{food.name}}"><img src="/media/{{food.image}}" alt="Dish1"></a> </div> </div> </div> {% endif %} {% endfor %} {% endfor %}<!-- Iso-Item .// --> </div> -
Django Formset field label in error messages
Is there a simple way to get the field label in an error message for a Django formset. I am able to do it in a normal form like so: {% if form.errors %} {% for field in form %} {% for error in field.errors %} <div class="alert alert-danger"> <strong>{{ field.label }}: {{ error|escape }}</strong> </div> {% endfor %} {% endfor %} {% for error in form.non_field_errors %} <div class="alert alert-danger"> <strong>{{ error|escape }}</strong> </div> {% endfor %} {% endif %} However, I'd like the same thing for the formset. The closest I've gotten is {% if formset.errors %} {% for dict in formset.errors %} {% for field, error in dict.items %} <div class="alert alert-danger"> <strong>{{ field }}: {{ error|escape }}</strong> </div> {% endfor %} {% endfor %} {% endfor %} {% for error in formset.non_field_errors %} <div class="alert alert-danger"> <strong>{{ error|escape }}</strong> </div> {% endfor %} {% endif %} However, this gives me the field name (e.g. pub_date) instead of the label (e.g. Publication Date). Any help much appreciated! -
Crispy FormHelper Wrap in Div
Trying to wrap my first_name and last_name fields with a div that has a class added to it. The form helper itself is working, because the 'id-exampleForm' and 'blueforms' is added to the form div, but it won't generate the custom div around the two fields. # Customize Crispy forms from crispy_forms.helper import FormHelper from crispy_forms.layout import Layout, Fieldset, ButtonHolder, Submit, HTML, Field, Div from django.utils.safestring import mark_safe from crispy_forms.bootstrap import ( PrependedText, PrependedAppendedText, FormActions) class ReservationForm(forms.Form): first_name = forms.CharField(label='First Name', required=True) last_name = forms.CharField(label='Last Name', required=True) email = forms.EmailField(required=True) def __init__(self, *args, **kwargs): super(ReservationForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_id = 'id-exampleForm' self.helper.form_class = 'blueForms' self.helper.layout = Layout( #Div('first_name', style="background: white;", title="Explication title", css_class="bigdivs") Field( Div( 'first_name', 'last_name', css_id = 'special-fields', style="background: white;", css_class="bigdivs" ), ) -
How to annotate a queryset with number of days since creation
I'm trying to do some complex ordering based on promotions: an article is promoted every 7th day since creation (the articles expire after 30 days). My approach is to annotate the queryset with the number of days since it was created, but the value of the annotated field (days_since_creation), in my code, is always 0. from datetime import timedelta from django.test import TestCase from django.db.models import ExpressionWrapper, F from django.db.models.fields import IntegerField from django.utils import timezone from .models import Article class ArticleTestCase(TestCase): def test_days_since_creation(self): now = timezone.now() objects_data = [ Article( title='Alrp', creation_date=(now - timedelta(days=5)) # 5 days ago ), Article( title='Bopp', creation_date=(now - timedelta(days=7)) # 7 days ago ), Article( title='Crkp', creation_date=(now - timedelta(days=14)) # 14 days ago ), ] Article.objects.bulk_create(objects_data) article_set = Article.objects\ .annotate( days_since_creation=ExpressionWrapper( now - F('creation_date'), output_field=IntegerField() ) ) for article in article_set: print(article.days_since_creation) # all 3 objects print "0" I expected the value for each object to be 5, 7, 14 repectively. I even tried DurationField but that just printed 0:00:00. After that I would annotate the queryset again with an order field that has the value 0 if the value of days_since_past is in [0, 7, 14, 21, 28,] or 1 otherwise, and then … -
How to properly use aggregate in Django
I have the following model: class InvoiceEntry(models.Model): invoice = models.ForeignKey(Invoice, on_delete=models.CASCADE, related_name='entries', verbose_name=_("Invoice")) line = models.CharField(max_length=500, verbose_name=_("Print Line")) text = models.TextField(null=True, blank=True, verbose_name=_("Print Text")) amount = models.PositiveIntegerField(verbose_name=_("Amount")) unit_price = models.FloatField(null=True, blank=True, verbose_name=_("Unit Price")) content_type = models.ForeignKey(ContentType, on_delete=models.PROTECT, null=True, blank=True, validators=[validate_invoice_target_models]) object_id = models.PositiveIntegerField(null=True, blank=True) is_separator = models.BooleanField(default=False) I want to obtain the total of a single invoice, so I get a query set using: invoice_entries = InvoiceEntry.objects.filter(invoice_id=2227), and if I apply values('amount', 'unit_price'), I get: {'amount': 0, 'unit_price': None} {'amount': 4, 'unit_price': 11.5} {'amount': 2, 'unit_price': 11.5} {'amount': 2, 'unit_price': 11.5} {'amount': 2, 'unit_price': 11.5} {'amount': 2, 'unit_price': 11.5} {'amount': 2, 'unit_price': 11.5} {'amount': 1, 'unit_price': 11.5} {'amount': 4, 'unit_price': 11.5} {'amount': 2, 'unit_price': 11.5} {'amount': 2, 'unit_price': 11.5} {'amount': 2, 'unit_price': 11.5} {'amount': 1, 'unit_price': 11.5} {'amount': 2, 'unit_price': 11.5} {'amount': 1, 'unit_price': 26.0} {'amount': 2, 'unit_price': 11.5} {'amount': 2, 'unit_price': 11.5} {'amount': 2, 'unit_price': 11.5} {'amount': 2, 'unit_price': 11.5} {'amount': 2, 'unit_price': 11.5} {'amount': 2, 'unit_price': 11.5} {'amount': 2, 'unit_price': 11.5} {'amount': 9, 'unit_price': 23.0} That counts for a total of 716.00, but when I try to aggregate: total = InvoiceEntry.objects.filter(invoice_id=2227).aggregate(amount=Sum('amount', field=('amount * unit_price'))) I get: {'amount': 52} I don't know what I am doing wrong. -
Admin configuration for multiple databases issue
My app is currently running with two different databases : default is on read-only and histo is the one I am writting on. I have change the admin.py file to change the default database: class MultiDBModelAdmin(admin.ModelAdmin): using='histo' def save_model(self, request, obj, form, change): # Tell Django to save objects to the 'histo' database. obj.save(using=self.using) def delete_model(self, request, obj): # Tell Django to delete objects from the 'histo' database obj.delete(using=self.using) def get_queryset(self, request): # Tell Django to look for objects on the 'histo' database. return super().get_queryset(request).using(self.using) def formfield_for_foreignkey(self, db_field, request, **kwargs): # Tell Django to populate ForeignKey widgets using a query # on the 'histo' database. return super().formfield_for_foreignkey(db_field, request, using=self.using, **kwargs) def formfield_for_manytomany(self, db_field, request, **kwargs): # Tell Django to populate ManyToMany widgets using a query # on the 'histo' database. return super().formfield_for_manytomany(db_field, request, using=self.using, **kwargs) When I run manage.py createsuperuser, I get the error: django.db.utils.ProgrammingError: relation "auth_user" does not exist I tried manage.py migrate --database=histo auth, but I still get this error. I think it's related to the fact that default database is on read-only. Can you help me on this? Thank you -
django.db.utils.IntegrityError: NOT NULL constraint failed: blog_article.created_on
I am creating a new model called article in blog app of django. the model is for registered and now want to add some data in all article fields which is defined in model.py file of blog app. Unfortunately, when save button is being clicked, browser comes up with IntegrityError. I tries to look other similar problems with django app, but could not gave me solution. Here is blog/models.py file: from django.db import models # Create your models here. class article(models.Model): title = models.TextField() author = models.TextField() abstract = models.TextField(null=False) #publish = models.DateTimeField() Here is blog/admin.py file: from django.contrib import admin from .models import article # Register your models here. admin.site.register(article) Here is Traceback: Traceback (most recent call last): . . . django.db.utils.IntegrityError: NOT NULL constraint failed: blog_article.created_on [06/May/2019 03:32:46] "POST /admin/blog/article/add/ HTTP/1.1" 500 186244 -
Django FutureFqType matching query does not exist
I'm setting up a new website using Django, and want to get an object name from sql . But it keep output the error objects.get matching query does not exist Where do I need to modify the code? views def predict1(request): name = '' loginstatus = False try: name = request.session['name'] loginstatus = True except: return HttpResponseRedirect('/login/?back=未來型預測') category_id = FutureMember.objects.get(member_name=name).type cname = FutureFqType.objects.get(type_id=category_id).type_name return render_to_response('predicts.html', {'cname': cname,'loginstatus': loginstatus, 'name': name}) html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <div><h2>根據投資人屬性測驗結果,您屬於<font color="#75CA20">{{ cname }} 您好!&nbsp;{{ name }}</font></h2> <form action="/predict/" method="post"> </div> </body> </html> models class FutureFqType(models.Model): type_id = models.CharField(primary_key=True, max_length=2) type_name = models.CharField(max_length=20) type_describe = models.TextField(blank=True, null=True) type_score = models.CharField(max_length=20) class Meta: managed = False db_table = 'future_fq_type' I expect the output of {{ cname }} to be data, but the actual can't output It comes out an error FutureFqType matching query does not exist. -
Django Model Choice Field How to return the primary key of the object instead of the display value
I am trying to use the modelchoicefield that Django provides; however, it is not behaving the way I expected. I want the display to the end user to be a string value from my model (which works), but return a the primary key of the Model when the user submits the form (not the display value). I attempted to use the to_field_name="id" on the Django form and it does render the values correctly when the HTML is rendered, but when the user submits the form the value I get back is the display value, not the primary key I am expecting. customer_edit_form.py annual_income = forms.ModelChoiceField(label='Annual income', to_field_name="id", queryset=cust_income_range.objects.all(), empty_label='-- None --') models.py # Annual Income Model class cust_income_range(models.Model): id = models.IntegerField(primary_key=True) range = models.CharField(max_length=50) def __str__(self): return self.range customer_view.py annual_income = form.cleaned_data['annual_income'] -
In Django 2.0, the Classe-based view is displaying the expected list but the function-based view does not
I am running the Django 2.0 project and component. I wrote the class-based view and the function-based view for comparison. The url http://localhost:8000/list/ displays the expected output. But when I type in http://localhost:8000/list-fbv/ in the browser, it comes back with the error: TemplateDoesNotExist at /list-fbv/ notes/notes_list.hmtl. What did I do wrong? views.py class NotesListView(ListView): context_object_name = 'notes_list' queryset = Notes.objects.all() def notes_list_view(request): queryset = Notes.objects.all() context = { 'notes_list': queryset } return render(request, "notes/notes_list.hmtl", context) urls.py: urlpatterns = [ path('list/', NotesListView.as_view(), name='notes_list'), path('list-fbv/', notes_list_view), path('detail/<int:id>/', NotesDetailView.as_view(), name='notes_detail'), path('detail-fbv/<int:pk>/', notes_detail_view), ] notes_list.html {% extends 'notes/_base.html' %} {% block content %} {% for note in notes_list %} <p>{{note.title}}</p> <p>{{note.text}}</p> <p>{{note.timestamp}}</p> {% endfor %} {% endblock content %}