Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
I want to get category id but I get None, what's the problem? Django
models.py class Post(models.Model): news = 'NW' articles = 'AR' POSITION = [ (news, 'Новость'), (articles, 'Статья') ] author_post = models.ForeignKey(Author, on_delete=models.CASCADE) category_type = models.CharField(max_length=2, default=news, choices=POSITION) date_created = models.DateTimeField(auto_now_add=True) category = models.ManyToManyField(Category) title = models.CharField(max_length=128, blank=False, null=False) text = models.TextField(blank=False, null=False) raitingPost = models.SmallIntegerField(default=0, verbose_name='Рэйтинг поста') class Subscription(models.Model): user = models.ForeignKey(to=User, on_delete=models.CASCADE, related_name='subscriptions') category = models.ForeignKey(to=Category, on_delete=models.CASCADE, related_name='subscriptions') signals.py @receiver(post_save, sender=Post) def subscribe_notify(instance, created, **kwargs): if not created: return print(instance.category) I need to get the category ID of a post that was just created. When I do instance.category I get None, you can see it on the screenshotenter image description here -
Django 1.11 Subquery annotate with .exclude
Is it not possible to exclude inside a queryset? I always receive this error: ValueError: This queryset contains a reference to an outer query and may only be used in a subquery. The part of the code I am wondering why is it not working: def get_queryset(self): return self.queryset.annotate( foo_count=Subquery( Foo.objects.exclude(code__hash=OuterRef('hash')) .values('code') .annotate(cnt=Count('pk')) .values('cnt'), output_field=IntegerField() ), ) Thanks for any possible solutions! -
Prefetching implicitly related model instances
Let's say I have two models that look like that: class UserRequest(models.Model): # other fields deal_type = models.CharField(choices=DEAL_TYPE_CHOICES, max_length=10) class Company(models.Model): # other fields deal_types_interested_in = ArrayField( models.CharField(max_length=10), ) # this field has a set of choices from DEAL_TYPE_CHOICES As you can see thoses models have no explicit relationship with each other but an "implicit" one via the deal types. What I want to achieve is to query UserRequests and "prefetch" all Companys that have matching deal types. If those two models had a direct relationship (m2m) I could use prefetch_related like that: requests = UserRequest.objects.prefetch_related( Prefetch('companies', Company.objects.filter(deal_types_interested_in__contains=OuterRef('deal_type'))) ) But that doesn't work as there is no relation companies on the UserRequest model. How can I prefetch those Company instances anyways? I especially want the prefetch to only be evaluated when the queryset is evaluated, just like with prefetch_related. In other words I'm looking for a prefetch_related but for implicitly related models with no explicit through table and no predefined relation to each other. In my use case I have even more criteria than only the deal_type to match Companies to User requests but I omitted them for sake of simplicity. -
1048, "Column 'materials' cannot be null"
I have created a model with following fields. But my checkbox is not working. models.py class Student(models.Model): name = models.CharField(max_length=300) # dob = models.DateField(max_length=8) age = models.IntegerField() gender = models.CharField(max_length=300) phn_no = models.IntegerField() email = models.EmailField() address = models.CharField(max_length=300) dept = models.CharField(max_length=300) course = models.CharField(max_length=300,blank=True) purpose = models.CharField(max_length=300) materials = models.CharField(max_length=300) This is the user interface created for my form. student.html {% load static %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="{% static 'css/custom.css' %}" rel="stylesheet" > <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap" rel="stylesheet" > <link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet" > <!-- <script src="http://kit.fontawesome.com/a076d05399.js"></script>--> <script src="{% static 'js/a076d05399.js' %}"></script> <!-- <meta name="description" content="{% block metadescription%} {% endblock %}">--> <!-- <title>{% block title %}{% endblock %}</title>--> <script> var deptObject = { "Computer Science": ["MCA","BCA","MSc Computer Science", "BSc Computer Science"], "Commerce": ["Mcom", "Bcom", "BBA"] } window.onload = function() { var deptSel = document.getElementById("dept"); var courseSel = document.getElementById("course"); for (var x in deptObject) { deptSel.appendChild(new Option(x, x)); } deptSel.onchange = function() { //empty Chapters- and Topics- dropdowns courseSel.length = 1; //display correct values for (var y in deptObject[this.value]) { courseSel.appendChild(new Option(deptObject[this.value][y], y)); } } } </script> </head> <body> <div class="container"> {% include 'navbar.html' %} <div class="container"> <div class="row justify-content-center"> <div … -
Stripe not working when getting needed variables from means other than GET parameters
I'm trying to submit a payment to Stripe using the documentation here. My goal is to submit a PaymentIntent and then check the status. The payment page I am creating is for a donation, so the amount can vary. As such, I'm trying to read the amount from my Django application into the stripe JS, and this is failing. This is my slightly modified code from the documentation example, which works fine: const items = [{ amount: "20" }]; let elements; initialize(); checkStatus(); document .querySelector("#payment-form") .addEventListener("submit", handleSubmit); // Fetches a payment intent and captures the client secret async function initialize() { const response = await fetch("/payment/intent/", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ items }), }); const { clientSecret } = await response.json(); const appearance = { theme: 'stripe', }; elements = stripe.elements({ appearance, clientSecret }); const paymentElement = elements.create("payment"); paymentElement.mount("#payment-element"); } The problem comes when I try to replace const items = [{ amount: "20" }]; Based on this answer, I've tried grabbing the value from a hidden value, by the following (showing hidden field in template and line in JS to obtain value from hidden field): <input type="hidden" id="amount" name="amount" value="20"> and const items = … -
Determine whether 2 files are of similar file extensions in Python
I'm working on a project including a webapp, with the option for storing smaller files. Currently an uploaded file can be updated to a new version IF the format (file extension) of the files are identical. MyPainting.jpg can be replaced by a new file MyPainting2.jpg. To implement this logic I'm simply performing the following check if file_type != local_file_type: return Exception("These files are not of simmilar format") I wish to extend this logic so that .jpg files can also be replaced by .jpeg, ppt can be replaced by pptx and so on. One solution would be to hardcode some collection of simmilar types, but that seems awfully annoying to deal with. TLDR: Does some package, or system exist that can tell me whether or not 2 file extensions are similar? (jpg --> jpeg are similar, but png --> pdf isn't) I'm working in the Django framework, so if I could put some attribute on my HTML input field, that does the same, that would be a solution aswell. Note: It doesn't really matter to me if PNG and JPG are found to be similar. In technical/practical use, I don't actually need the files to be similar, I could update a … -
many-to-many link table - have multiple of FKs linked - general concept question (Django)
While this is Django related it is more of a concept question that is confusing me. I understand how to set this up in Django. I feel I have solved this before but it would have been a while ago and now suddenly I can't wrap my head around it anymore. This seems so simple so surely I must have a blank moment here? Here is a simple example: Pizza and Topings with a trough (m2m link) table that joins both. Question: How can I have multiples of one type linked to an instance of the other without creating additional fields for it? The issue is that those fields are all FK ids of course. I want an option to have unlimited toppings for a Pizza within ONE single column. Is that doable? Pizza Table Pizza A Pizza B Toppings Table Topping 1 Topping 2 Through Table Pizza A | Topping 1 Pizza A | Topping 2 Pizza B | Topping 1 Pizza B | Topping 1 & Topping 2 <<<<<---- how to do this with 1 column instead of 2? The first answer that came to me was to create a list or dict (or similar) within that DB … -
Django Admin Tabural Inline Throwing Error
I have created a Category and Product model when In the product model I have created a category field which is foreign key relation to the category model. class Category(models.Model): name = models.CharField(max_length=100) icon= models.ImageField(upload_to='CategoryIcons/', blank=True, null=True) created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return self.name Here is the Product Model - class Product(models.Model): title = models.CharField(max_length=200) category = models.ForeignKey(Category, on_delete=models.CASCADE, related_name='products') productImages = models.ManyToManyField(ProductImages) price = models.IntegerField() qty = models.IntegerField(default=0) shortDescription = models.TextField(blank=True, null=True) active = models.BooleanField(default=True) created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return f'{self.title}{ self.category}' Now when I try to use Django tabural Inline class with it says SystemCheckError: System check identified some issues: ERRORS: <class 'shop.admin.CategoryInline'>: (admin.E202) 'shop.Category' has no ForeignKey to 'shop.Product'. admin.py file code - from django.contrib import admin from .models import Category, ProductImages, Product, Order, Shipping, OrderItem # Register your models here. class CategoryInline(admin.TabularInline): model = Category readonly_fields = ('id', 'created_at') extra = 2 class ProductAdmin(admin.ModelAdmin): inlines = [ CategoryInline, ] admin.site.register(Category) admin.site.register(ProductImages ) admin.site.register(Product, ProductAdmin) admin.site.register(Order) admin.site.register(Shipping) admin.site.register(OrderItem) I am confused that where I am doing wrong as in most of the places I see the same formate and code. Please help me out. -
form.as_p displays only one first input in Django template
I'm trying to use my form in django template but only one input displaying on the page Template <form method="post"> {% csrf_token %} {{ form.as_p }} <input type="submit" value="Save"> </form> Screenshot from page Form class JournalRecordForm(forms.ModelForm): class Meta: model = JournalRecord fields = ('shutdown_datetime', 'approximate_turn_on_datetime', 'shutdown_type', 'shutdown_reason', 'additional_information') Model class JournalRecord(models.Model): record_creation_datetime = models.DateTimeField(verbose_name='Дата і час запису', auto_now_add=True, null=False, blank=False) record_close_datetime = models.DateTimeField(verbose_name='Дата і час відміни заяви', default=None, null=True, blank=True) ...... additional_information = models.TextField(verbose_name='Додаткова інформація', null=True, blank=True) View class JournalRecordCreateView(CreateView, LoginRequiredMixin, PermissionRequiredMixin): permission_required = ('dispatcher.add_journalrecord') model = JournalRecord form_class = JournalRecordForm fields = '__all__' I have no idea what is wrong. I tried: manually pass JournalRecordForm() to template context change class based CreateView to View. -
when django-adminplus is used , authentication and authorization section is not available in the django menu
When we add adminplus in django to add custom views, the authentication and authorization section disappears. Why? -
Django own templatestags
I have a question. I created own tags in django like this: from django import template from my_app.models import Post register = template.Library() @register.simple_tag def last_create_members(last=5): return Post.objects.order_by('created')[:5] And I wanted to displayed it. So when I display it this way: {% last_create_members %} everything is good and I see 5 Posts. But when I want to add tag in loop : {% for p in last_create_members %} <p>{{ p }}</p> {% endfor %} I can't see anything (empty space). What am I doing wrong? and can I add tag in loop that way? -
Unable to set cookie in React by using Django
I created a React website that uses API to communicate with the Django backend. I use djangorestframework to create API. I need to set cookie to react but there is no update cookie on React site. views.py class Test(generics.CreateAPIView): def post(self,request, *args, **kwargs): response = Response() response.set_cookie('test_cookie', 'MY COOKIE VALUE') return response How to fix this problem? What topic should I know to fix that problem? -
Django: get model's fields name
I am trying to create a table in react that uses as table information from a django backend. I would like to fetch the table's columns from the API, so I tried updating the model: class Activity(models.Model): aid = models.AutoField(primary_key=True) uid = models.ForeignKey(USER_MODEL, default=1, verbose_name="Category", on_delete=models.SET_DEFAULT, db_column="uid") rid = models.IntegerField() action = models.TextField(max_length=254, blank=True, null=True) time = models.TextField(max_length=254, blank=True, null=True) table = models.TextField(max_length=254, blank=True, null=True) class Meta: managed = False db_table = "activity" @property def fields(self): return [f.name for f in self._meta.fields] I am trying to use fields() as the method to get all the model's "column" names, so that I can place them in the API's response, but it does not work. How can I get a django model's field names from the model's meta? -
How to use model and serializer in Python to connect to various databases using the mysql connector?
I need to connect multiple instances (nearly 100). Is there a way to connect multiple instances of mysql connector python without using a cursor? I already tried using cursor. common Django methods? connection_pool = pooling.MySQLConnectionPool( pool_name=dbname, pool_size=1, pool_reset_session=True, host=host, database=dbname, user=os.getenv("DYNAMIC_DB_USERNAME"), password=os.getenv("DYNAMIC_DB_PASSWORD"), ) connection_object = connection_pool.get_connection() with connection_object .cursor(buffered=True) as cursor: cursor.execute("""select * from employee""") row = dictfetchall(cursor) I'll need to do the same thing with the model and serializer methods. Is it possible to rewrite in -
Reverse for 'save-review' not found. 'save-review' is not a valid view function or pattern name
I have error in Django: "django.urls.exceptions.NoReverseMatch: Reverse for 'save-review' not found. 'save-review' is not a valid view function or pattern name." I study django through YouTube, I do everything as in the video, but I get an error. When there is no authorization and "Add review" button is hidden, the page works fine. But when "Add review" button is shown, the product page doesn't load and throws an error. product-detail.html <div class="col-md-6"> <h3 class="my-3">Обзоры - 4.5/5 <i class="fa fa-star text-warning"></i> {% if user.is_authenticated %} <button type="button" data-toggle="modal" data-target="#productReview" class="btn btn-warning bt-sm float-right">Add review</button> {% endif %} </h3> <div class="card"> <div class="card-body" style="max-height: 400px; overflow; auto;"> <!-- Detail --> <blockquote class="blockquote text-right"> <small>Good product</small> <footer class="blockquote-footer">John Lenon <cite title="Source Title"> <i class="fa fa-star text-warning"></i> <i class="fa fa-star text-warning"></i> <i class="fa fa-star text-warning"></i> <i class="fa fa-star text-warning"></i> </cite> </footer> </blockquote> </div> </div> </div> </div> {% if user.is_authenticated %} <!-- Product Review --> <div class="modal fade" id="productReview" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel">Product Review</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> </div> <div class="modal-body"> <form id="addForm" method="post" id="addForm" action="{% url 'save-review' data.id %}"> {% csrf_token %} <table class="table table-bordered"> {{form.as_table}} <tr> <td colspan="2"> <button type="submit" class="btn … -
is it possible to register only a view in django admin and not any model? using django 3.2 version
The requirement is to register views in the django admin interface just like the models, which will serve as hyperlink and execute some code in the views to display some on-screen data. Is it possible. Looks like adminplus doesnt work with this version of django for t he same. Any other tool to serve this purpose? -
Refused to apply style due to unsupported MIME type
Refused to apply style from 'http://127.0.0.1:8000/plugins/font-awesome-4.7.0/css/font-awesome.min.css'%20%7D' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. ``STATIC_URL = 'static/' STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]`` STATIC_ROOT = os.path.join(BASE_DIR, 'assets') MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') `` -
is there a way to make this filter in Django [closed]
I don't know what is the name of this filter method , but I want to do such like it in my project , and don't even know its name Such like this filter such like categories and every category , I could the products inside it or not , or such like this picture . -
how to solve this problem I don't know how to make a user with his login can enter the application
in login user.save() ^^^^ UnboundLocalError: cannot access local variable 'user' where it is not associated with a value [21/Feb/2023 09:52:15] "GET /login HTTP/1.1" 500 63809 where is the problem -
Django MongoDB configuration works but throw CLI error
I'm trying to configure Mongo DB with Django and works, the database was created, migrations are done, the documents appears and i can save elements, but migrations command throws and error. The Django settings: DATABASES = { 'default': { 'ENGINE': 'djongo', 'NAME': MONGO_NAME, 'CLIENT': { 'host': MONGO_URL, 'username': MONGO_NAME, 'password': MONGO_PASSWORD, 'authSource': 'admin', 'authMechanism': 'SCRAM-SHA-1', }, 'ENFORCE_SCHEMA': False } } The CLI error bash-5.0# python manage.py makemigrations order Migrations for 'order': order/migrations/0001_initial.py - Create model Order bash-5.0# python manage.py migrate order Operations to perform: Apply all migrations: order Running migrations: Applying order.0001_initial...This version of djongo does not support "NULL, NOT NULL column validation check" fully. Visit https://nesdis.github.io/djongo/support/ Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/djongo/cursor.py", line 51, in execute self.result = Query( File "/usr/local/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 784, in __init__ self._query = self.parse() File "/usr/local/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 876, in parse raise e File "/usr/local/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 857, in parse return handler(self, statement) File "/usr/local/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 928, in _insert query = InsertQuery(self, self.db, self.connection_properties, sm, self._params) File "/usr/local/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 340, in __init__ super().__init__(*args) File "/usr/local/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 62, in __init__ self.parse() File "/usr/local/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 410, in parse self._fill_values(statement) File "/usr/local/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 368, in _fill_values raise SQLDecodeError djongo.exceptions.SQLDecodeError: Keyword: None Sub SQL: None FAILED SQL: ('INSERT INTO "django_migrations" … -
How to extend DRF generic views to generate Open API schema?
I'm trying to generate Open API schema with Django Rest Framework and DRF Spectacular, The option 2 works well and return component schema well but but i would like to use option 1 to customize parent class of child views. Option 1: urls.py: path( 'learningmaterialcategory/', LearningMaterialCategoryListApiView.as_view( model=LearningMaterialCategory ), name='learningmaterialcategory_list' ), views.py: class BaseApiView(APIView): serializer_class = None def setup(self, request, *args, **kwargs): self.app_name = self.model._meta.app_label super().setup(request, *args, **kwargs) def get_serializer_class(self): if self.serializer_class is None: serializer_class_name = self.model.__name__ + 'Serializer' self.serializer_class = getattr(__import__(f'{ self.app_name }.api.serializers', fromlist=[serializer_class_name]), serializer_class_name) return self.serializer_class class GenericListApiView(BaseApiView, generics.ListAPIView): model = None permission_classes = (permissions.AllowAny,) def setup(self, request, *args, **kwargs): super().setup(request, *args, **kwargs) filter_class_name = self.model.__name__ + 'Filter' self.filterset_class = getattr(__import__(f'{ self.app_name }.filters', fromlist=[filter_class_name]), filter_class_name) def get_queryset(self): return self.model.objects.all() class LearningMaterialCategoryListApiView(GenericListApiView): pass schema.yaml: /api/services/learningmaterialcategory/{id}/detail/: ... responses: '200': description: No response body Option 2: urls.py: path( 'learningmaterialcategory/', LearningMaterialCategoryListApiView.as_view(), name='learningmaterialcategory_list' ), views.py: class LearningMaterialCategoryListApiView(generics.ListAPIView): queryset = LearningMaterialCategory.objects.all() serializer_class = LearningMaterialCategorySerializer schema.yaml: ... components: schemas: LearningMaterialCategory: type: object properties: id: type: integer readOnly: true title: type: string maxLength: 50 required: - id - title -
adding limit for a models choices in Django
I have a model for order status, this model creates a table with a foreign key to order model and saves a status for order ( like pending, accepted, failed, sending and received ) and a time of the status added it is auto generate in with pending when the order is created and other ones have an API with post method for each order now, I wanna limit the choices for API in this form: If there is a pending status when getting order status list the choices need to limited to accepted and failed If there is a accepted status when getting order status list the choices need to limited to sending and received If there is a failed status when getting order status list the choices need to limited to pending and accepted If there is a sending status when getting order status list the choices need to limited to received this is the order status model: class OrderStatus(models.Model): order = models.ForeignKey(Order, on_delete=models.PROTECT, related_name='status') ORDER_STATUS_PENDING = 'P' ORDER_STATUS_ACCEPTED = 'A' ORDER_STATUS_FAILED = 'F' ORDER_STATUS_SENDING = 'S' ORDER_STATUS_RECEIVED = 'R' ORDER_STATUS_CHOICES = [ (ORDER_STATUS_PENDING, 'Pending'), (ORDER_STATUS_ACCEPTED, 'Accepted'), (ORDER_STATUS_FAILED, 'Failed'), (ORDER_STATUS_SENDING, 'Sending'), (ORDER_STATUS_RECEIVED, 'Received') ] status = models.CharField( max_length=1, … -
djano support nested or flat values for a single field using single serializer
I have a DateRangeSerializer serializer that validates a payload. import rest_framework.serializers as serializer from django.conf import settings class ValueNestedSerializer(serializer.Serializer): lower = serializer.DateTimeField(input_formats=settings.DATETIME_INPUT_FORMATS, required=True) upper = serializer.DateTimeField(input_formats=settings.DATETIME_INPUT_FORMATS, required=True) class DateRangeSerializer(serializer.Serializer): attribute = serializer.CharField(default="UPLOAD_TIME", allow_null=True) operator = serializer.CharField(default="between_dates") value = ValueNestedSerializer(required=True) <---- this could be set to `False` to address the issue # lower = serializer.DateTimeField() # upper = serializer.DateTimeField() timezone = serializer.CharField(default="UTC") timezoneOffset = serializer.IntegerField(default=0) The respective payload: "date_range": { "attribute": "date_range", "operator": "between_dates", "value": { "lower": "2023-01-06T00:00:00Z", "upper": "2023-02-05T23:59:59Z" } } Here value field is nested. But there are few implementations where lower and upper are flat values and not nested. Like: "date_range": { "lower": "2023-01-21T00:00:00Z", "upper": "2023-02-21T23:59:59Z" } Now, I can set the value required=False and add lower/upper as flat fields like I've mentioned in the comments above. But I want to enforce it more "properly". Is there any other way where I can handle both payloads for nested and flat lower-upper values? -
django equivalent for mysql's JSON_OVERLAPS
i basically have a model named as Teachers and my table look something like this Teachers id - int student_ids - jsonfield ( eg - [1,2,3,4]) so now my usecase is something like this i have a student_list - [12,213,43,123,345,43,1] so now i want to get all teachers that have these students in their student_ids list so if we are talking about raw sql, then it can be easily acheived with JSON_OVERLAPS, something like JSON_OVERLAPS('teachers.auction' , student_list) but as i am currently using django 3.2 and mysql 8, i want to know how can we do similar thing in DJANGO ORM itself i know about __contains and all in django, but it will not work in my usecase ( from what i undestand , json_Contains will search that every element in student_list is present in teacher.student_ids or not), instead i want which teacher.students_ids contains any of the element in student_list -
Context variables not being passed to template in Django class-based view
Banging my head against a wall.. I'm trying to return a table of Job objects, with views separated by month. I'm passing 'year' and 'month' variables through get_context_data, yet in my template they're returning blank strings. Even ChatGPT can't find anything wrong lol. Can anyone spot something? Here's my view: class pipelineMonthView(SingleTableMixin, MonthMixin, ListView): model = Job table_class = JobTable form_class = JobForm bulk_actions = PipelineBulkActionsForm template_name = "main_app/pipeline_by_month.html" def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['job_form'] = self.form_class context['bulk_actions'] = self.bulk_actions context['year'] = 2023 #hardcoded for debugging context['month'] = 2 #hardcoded for debugging return context def get_queryset(self): queryset = super().get_queryset() print(f'the result of self.get_month: {self.get_month()}') queryset = queryset.filter(job_date=self.get_month()) return queryset My URL, including URLs from main_app: path('pipeline/<int:year>/<int:month>/', views.pipelineMonthView.as_view(model=Job), name="pipeline-by-month"), And my URL tag: {% url 'main_app:pipeline-by-month' year month %} Here's the traceback: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/core/handlers/base.py", line 204, in _get_response response = response.render() File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/template/response.py", line 105, in render self.content = self.rendered_content File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/template/response.py", line 83, in rendered_content return template.render(context, self._request) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/template/backends/django.py", line 61, in render return self.template.render(context) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/template/base.py", line 170, in render return self._render(context) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/template/base.py", line 162, in _render return self.nodelist.render(context) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/template/base.py", line …