Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django can't find full url but can find path
I've got gulp working with django, and I'm trying to serve everything from my myapp/static/myapp/ folder. I'm using the shell to troubleshoot and for some reason the resolver can find the path but not the full url. #enter shell with: # > ./venv/Scripts/python ./myapp/manage.py shell import django.urls as urls import os #no port urls.resolve('http://localhost/static/myapp/favicon/site.webmanifest.json') urls.resolve('http://127.0.0.1/static/myapp/favicon/site.webmanifest.json') #django dev server port urls.resolve('http://127.0.0.1:8000/static/myapp/favicon/site.webmanifest.json') urls.resolve('http://localhost/static/myapp/favicon/site.webmanifest.json') #browsersync port urls.resolve('http://127.0.0.1:3000/static/myapp/favicon/site.webmanifest.json') urls.resolve('http://localhost:3000/static/myapp/favicon/site.webmanifest.json') #all the above produce an error like below #output Traceback (most recent call last): File "<console>", line 1, in <module> File "C:\Users\jmarshall\source\venv\lib\site-packages\django\urls\base.py", line 25, in resolve return get_resolver(urlconf).resolve(path) File "C:\Users\jmarshall\source\venv\lib\site-packages\django\urls\resolvers.py", line 576, in resolve raise Resolver404({'path': path}) django.urls.exceptions.Resolver404: {'path': 'http://127.0.0.1:3000/myapp/favicon/site.webmanifest.json'} ############################################################################################ # now if I resolve with just the path: urls.resolve('/static/myapp/favicon/site.webmanifest.json') ##output ResolverMatch(func=django.views.static.serve, args=(), kwargs={'path': 'myapp/favicon/site.webmanifest.json', 'document_root': 'C:\\Users\\jmarshall\\source\\myapp\\myapp\\../static'}, url_name=None, app_names=[], namespaces=[], route=^static/(?P<path>.*)$) ############################################################################################ m = urls.resolve('/static/myapp/favicon/site.webmanifest.json') os.path.exists(os.path.join(m.kwargs['document_root'], m.kwargs['path'])) ##output True ############################################################################################ On the front end, the static files are most certainly 404. Any idea what's happening? -
How can I create an upload_to folder using a field belonging to the model that is simultaneously being created?
Context: I'm building a car dealership app using Django 3.1.4, and trying to implement a feature where by every time a new ad is created, so is a new folder (via the upload_to method) within /media/ that will only contain that newly created ad's photos. I've gotten this working somewhat using date formatting (see below) but I need this new folder to be named one of the fields belonging to the model(see the second code snippet). photo_4 = models.ImageField(upload_to='photos/%Y/%m/%d', blank=True) For example, every newly created ad would use the title field.. class Vehicles(models.Model): CONDITION_CHOICES = [("Brand New","Brand New"),("Used", "Used")] FUEL_CHOICES = [("Petrol","Petrol"),("Diesel", "Diesel"),("Electric", "Electric"),("Hybrid", "Hybrid")] TRANSMISSION_CHOICES = [("Automatic","Automatic"),("Manual", "Manual")] title = models.CharField(max_length=200, default = "Ad Title & Folder Name") def folder_name(self, title): return self.title make = models.CharField(max_length=100) Ideally then, the media folder would look something like /media/ Opel Astra VXR/ Mercedes E200/ I understand that many others have done something similar but all the examples I found use the 'user' and instead I need to use a model field (belonging to the model that is being created) as the folder name. Closing notes: The function in the second code snippet was just something I was trialing. Also, this is still … -
Django 3.0 - View a PDF in the browser
I simply want to click a link and view, in the browser, a PDF that I have uploaded to my Django project. To be sure in the Django docs (https://docs.djangoproject.com/en/3.1/howto/outputting-pdf/) about how to create reports is not at all what I'm looking to do, I don't need to generate a PDF, I already have the ones I need. (This comes up a LOT in other answers.) No luck with: Render HTML to PDF in Django site (No surprise, it's 11 years) Or: Django - JS : How to display the first PDF page as cover (somewhat surprised this is not the only time that a suggestion containing pdf.js occurs, I simply get an empty white square on me page with no further errors). I have as well attempted embedding the PDF in a template with no luck. (Recommended way to embed PDF in HTML?) (Tried or , and as you see in the link pdf.js once more. No go.) How, generally, would one accomplish this specifically in Django 3.x? Thanks. -
Python/Django: No module named dj_database_url
I know this issue has been touched several times but in this case, I am trying to ask for advices more than 'whats going on with dj_database_url', which it has been answered already. I am a JS developer and therefore have worked exclusively with node environments, but I received a task to fix with a web application (server-side rendered) built with Django, something that is completely new to me. Anyway, I have been reading about this framework and so on, but before I start typing commands as crazy, I would like to hear you what should I consider first? The tasks are mainly styling and accessibly issues, so what I thought is "okey, I just need to fire the server and start fixing styling stuffs", but before that, I might need to download packages and doing some configuration?. In the repo that they sent me, it is only stated the run commands: Setup $ python manage.py migrate $ python manage.py runserver Cool, but there is when the issues come. MacOS, the system that I use, comes already with Python2.7 and 3.9, and some people state that when you run the commands, use the version, otherwise could not work (ex: python2.9 … -
Django must clean data from xml before save it to database?
I import the data from an xml file, using a script and not a form. products = tree.findall('item') for product in products: prod = Product() prod.name = product.find('title').text prod.description = product.find('description').text prod.save() If i use save() method, should I clean the data from xml before save it to database? Thank you -
Test case for a django view
I need help in understanding how to write a particular test case for a view and I can not get my head around it. I am basically using the polls app in Django docs example but I have extended it quite a bit. So I have a view called createQuestion that renders createQuestion.html. The user can add a question and can add a minimum of 1 and a max of 10 choices to each question. If the user tries to submit with completing the requirements an error will be shown and the form won't submit till at-least one choice is added or if the user tries to add more than 10 choices. I also check the number of choices submitted in the backend as well, if more than 10 come or less than 1 come the createQuestion.html will render again giving the error message "Incorrect number of choices". What I need help with I don't understand how I can write a test case for this view in tests.py to check if the page contains the error messages if the user tries to submit more than 10 or less than 1. Code Here is the code for models.py, view in views.py, … -
is there any way to connect a Django app and Java app using WebSockets?
At the moment I am in a project in which it is divided into three groups: the first in java that gathers information and exposes it through API Rest, the second (to which I belong) in django that brings the information from the first group, processes it and It exposes it to the third party that is the general front of the application. Currently the first group is exposing a WebSocket to which I want to connect and later through another WS exposing the information to the third. I was reviewing Django Channels to be able to do this and although I have been looking I can not find how to do it. I appreciate if you could guide me with any ideas to do this or if you have done something similar in the past. -
Any suggestions about how to refresh a js file in django, I changed the URL but its still loading the privious one
` Im getting this error GET http://127.0.0.1:8000/move/move_type_rapport 404 (Not Found) But as you can see below, the URL is http://127.0.0.1:8000/move/move_type_rapport const getChartData =() => { console.log("fetching"); fetch("/move/move/move_type_rapport") .then((res) => res.json()) .then((results) => { console.log("results", results); const type_data = results.move_type_data; const [labels, data] = [ Object.keys(type_data), Object.values(type_data), ]; renderChat(data, labels); }); }; document.onload = getChartData();` -
Django Rest Framework save data into not default database
I have model: class TableUser(models.Model): name = models.CharField(max_length=60) lastname = models.CharField(max_length=60) class Meta: db_table = 't_users' def __str__(self): return self.name serializer look like: class UserListSerializer(serializers.ModelSerializer): class Meta: model = TableUser fields = ('name', 'lastname') I would like to save new data into database (not default) { "name": "one", "lastname": "two" } Settings: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), }, 'remote': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'test_db', 'USER': 'admin', 'PASSWORD': 'admin123!', 'HOST': 'localhost', } } views.py @api_view(['POST']) def saveuser(request): if request.method=="POST": saveserialize=UserListSerializer(data=request.data) if saveserialize.is_valid(): saveserialize.save(using='remote') return Response(saveserialize.data, status=status.HTTP_201_CREATED) return Response(saveserialize.data, status=status.HTTP_400_BAD_REQUEST) i get: t_users() got an unexpected keyword argument 'using' if I change saveserialize=UserListSerializer(data=request.data) to saveserialize=UserListSerializer(data=request.data, many=True) then I get Got AttributeError when attempting to get a value for field name on serializer UserListSerializer. The serializer field might be named incorrectly and not match any attribute or key on the str instance. Please help me, what am I doing wrong -
Django: get_queryset after get_context_data
I am filtering the Project model objects by authenticated user in get_context_data in my ListView class myprojects(LoginRequiredMixin, ListView): model = Project template_name = 'my_project_list.html' ordering = ['project_title'] def get_context_data(self, *args, **kwargs): context = super(myprojects, self).get_context_data(**kwargs) context['my_projects'] = Project.objects.filter(engineer=self.request.user) return context In template {% for my_project in my_projects %} {{ my_project }} {% endfor %} I have a form in my template to search for projects and I use a get_queryset on the same ListView. I receive the search but it does not filter in the template class myprojects(LoginRequiredMixin, ListView): model = Project template_name = 'my_project_list.html' ordering = ['project_title'] def get_context_data(self, *args, **kwargs): context = super(myprojects, self).get_context_data(**kwargs) context['my_projects'] = Project.objects.filter(engineer=self.request.user) return context def get_queryset(self, *args, **kwargs): context = super().get_queryset(*args, **kwargs) search = self.request.GET.get('buscar', None) print(search) if search: context = context.filter( Q(project_title__icontains=search) | Q(category__title__icontains=search) ).distinct() return context Note: When i use {% for project in object_list %} instead of {% for project in my_projects %}, it searches without problems, but I no longer have the filter by user -
Dynamically add ordered number to each object in Paginated response from Django Rest
I'm currently getting a standard paginated response using Django REST framework, however I need to add a number to each object response in the order it is retrieved. 1,2,3,4,5 etc. It must be calculated each time dynamically if new results are added and retrieved by the user. It would go from this: { "next": "http://localhost:8000/api/home/?page=2", "previous": null, "count": 105, "results": [ { "title": "example1", "description": "foobar1", }, { "title": "example2", "description": "", }, ... ] to looking like this: { "next": "http://localhost:8000/api/home/?page=2", "previous": null, "count": 105, "results": [ { "key": 1, "title": "example1", "description": "foobar1", }, { "key": 2, "title": "example2", "description": "", }, ... ] This would also include the next page in the paginated response, e.g. 21, 22, 23, 24. If a user then refreshes the page and new data is found and retrieved it would recalculate and add key numbers again. How would one go about this? Thanks! -
django server refused connection on localhost
Hi guys I have a brand new Django setup on my computer, I ran the command runserver, and I get an ERR_CONNECTION_REFUSED in chrome, localhost is added to allowed_hosts and I get no error in django, when I check for the port it is not active, I am running Django in wsl and accessing chrome from windows on the same machine I have tried adding to my IP, changing browser, adding to allowed hosts, I initially had this issue in another project and I set up this new project to see if the problem would resolve, it didn't and the new project is completely clean no way something could be messed up there any help would be greatly appreciated thanks in advance edit: I tried running the server in windows and finally got an error Error: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions -
Why is my CSS file is not loading (Django)
So my directory is CLASSMGMTSYS/classMgmt/static/classMgmt/css/indexCss.css ----------------------/templates/index.html When I run the server it says: "GET /static/classMgmt/css/index.css HTTP/1.1" 404 1695 Not Found: /favicon.ico index.html {% load static %} <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="{% static 'classMgmt/css/index.css' %}"> <title>Index Page</title> </head> <body> <div> {% if class_list %} <ul> {% for class in class_list %} <h1> <a href="{% url 'classMgmt:class_details' class.id %}">{{ class.name }}<a/> </h1> {% endfor %} </ul> {% else %} <p>No class are available at the moment. Try again later.</p> {% endif %} </div> <div> <button type='button'><a href='{% url "classMgmt:add_class" %}'>Add Class</a></button> </div> </body> </html> static/Mgmt/css/index.css li a { color: green; } -
Python (django) call two management commands at the same time
I'm writing unit tests for my management commands. I would like to run my two management commands meanwhile by using call_command() function. How can I do that? I need to run them at the same time because they do work together, one creates data and the other uses that data. -
Django: query caching not working as expected
I'm working on optimizing my Django app. Some of the caching behavior from at least one of the queries is not working as expected and I am running out of ideas. For ease, this is a simplified example. Suppose I have 3 models: User, FriendsList, Gender. User serves as Foreign Key to each, FriendsList (as user_id and befriended_user_id) and Gender (as user_id). The tables are fully normalized. The goal is to display a User's Friendslist, with entries sorted by Gender. I wanted to minimize the number of database hits by optimally utilizing query caching. in views.py: 1 female_friends = [] 2 male_friends = [] 3 4 gender_query = Gender.objects.select_related().all() 5 # no hits to database 6 7 friendslist_query = FriendsList.objects.filter(user_id = request.user.id).select_related().all() 8 # 2 hits to database 9 10 for friendslist in friendslist_query: 11 # 1 hit to database (total for all entries) 12 13 friend_entry = friendslist.befriended_user_id.id 14 # no hits to database 15 16 gender = gender_query.get(user_id = friends_entry) 17 # 1 hit to database (for each time friendslist_query is iterated over) 18 19 gender_type = gender.gender_type 20 # no hits to database 21 22 if gender_type == 'True': 23 female_friends.append(friendslist) 24 # no hits to database … -
No module names urls
Error: Importerror Python version: 2.7 Django version: 1.8.4 Whenever i start my localhost server, i get this error, the error is pointing towards from django.urls import re_path in grapelli/urls.py, code provided in the end. *** **ImportError at / No module named urls Request Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 1.8.4 Exception Type: ImportError Exception Value: No module named urls Exception Location: /mnt/c/users/verma/desktop/opine/env/local/lib/python2.7/site- packages/grappelli/urls.py in <module>, line 3 Python Executable: /mnt/c/users/verma/desktop/opine/env/bin/python Python Version: 2.7.17 Python Path: ['/mnt/c/users/verma/desktop/opine', '/mnt/c/users/verma/desktop/opine/env/lib/python2.7', '/mnt/c/users/verma/desktop/opine/env/lib/python2.7/plat-x86_64-linux-gnu', '/mnt/c/users/verma/desktop/opine/env/lib/python2.7/lib-tk', '/mnt/c/users/verma/desktop/opine/env/lib/python2.7/lib-old', '/mnt/c/users/verma/desktop/opine/env/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/mnt/c/users/verma/desktop/opine/env/local/lib/python2.7/site-packages', '/mnt/c/users/verma/desktop/opine/env/lib/python2.7/site-packages']*** Server time: Wed, 6 Jan 2021 03:07:09 +0530** /mnt/c/users/verma/desktop/opine/env/local/lib/python2.7/site-packages/grappelli/urls.py in grappelli/urls.py : I have used grappelli in my project for admin access. ** # coding: utf-8 from django.urls import re_path from .views.related import AutocompleteLookup, M2MLookup, RelatedLookup from .views.switch import switch_user urlpatterns = [ # FOREIGNKEY & GENERIC LOOKUP re_path(r'^lookup/related/$', RelatedLookup.as_view(), name="grp_related_lookup"), re_path(r'^lookup/m2m/$', M2MLookup.as_view(), name="grp_m2m_lookup"), re_path(r'^lookup/autocomplete/$', AutocompleteLookup.as_view(), name="grp_autocomplete_lookup"), # SWITCH USER re_path(r'^switch/user/(?P<object_id>\d+)/$', switch_user, name="grp_switch_user"), ] ** Error in line no. 1: from django.urls import re_path How do I fix this, because URLs is not another module created by me, it's an inbuilt one in Django. -
Django - Use Ajax to filter and display projects per category
I would like to use Ajax in my project in order to filter projects per category and display them in my template. I read a couple of articles but unfortunately i cannot figure out a way of how to implement it. Any help is appreciated. views.py class CategoryDetailView(ListView): model = Category context_object_name = 'projects_categ' template_name = 'work/work.html' def get_queryset(self): self.category = get_object_or_404(Category, pk=self.kwargs['pk']) return Project.objects.filter(category=self.category).order_by('-id') def get_context_data(self, **kwargs): context = super(CategoryDetailView, self).get_context_data(**kwargs) return context urls.py path('category/<int:pk>/<slug:slug>', CategoryDetailView.as_view(), name='category-list'), work.html <div class="filterings"> <div class="filtering-wrap"> <div class="filtering"> <div class="selector"></div> {% for category in categories %} <button type="button" data-filter="brand" data="branding" value="branding" class="filter-category"> <a href="#">{{ category.title }}</a> </button> {% endfor %} </div> </div> </div> -
Django pagination, ordered and search
I've a question about what is the proper way to implement a pganiation with a search and possibility to reorder on column on a table in Django. What trigger me is thatt keep pagination true with the right data I duplicate three times all my HTML pagination with different data to keep the "state" of my pagination + order/searchTerm. This is what I've done so far : Search.py def searchProjects(request,user): querySearch = request.GET.get("q") queryOrderBy = request.GET.get("orderby") if querySearch: projects = Project.objects.filter( Q(reference__icontains=querySearch) | Q(name__icontains=querySearch) ).distinct() paginator = Paginator(projects, 10) page_number = request.GET.get('page', 1) paginateProjects = paginator.get_page(page_number) paginateProjects.searchTerm = querySearch elif queryOrderBy: projects = Project.objects.order_by(queryOrderBy) paginator = Paginator(projects, 10) page_number = request.GET.get('page', 1) paginateProjects = paginator.get_page(page_number) paginateProjects.orderby = queryOrderBy else: if user.is_admin: projects = Project.objects.order_by('-created') else: projects = Project.objects.filter(creator=user).order_by('-created') paginator = Paginator(projects, 10) page_number = request.GET.get('page', 1) paginateProjects = paginator.get_page(page_number) return paginateProjects Render.py paginateProjects = searchProjects(request,user) context = { 'projects': paginateProjects } return render(request, "main/globale/home.html", context) Home.html {% if projects.searchTerm %} {% if projects.has_previous %} <a href="?page=1&q={{ projects.searchTerm }}">&laquo; first</a> <a href="?page={{ projects.previous_page_number }}&q={{ projects.searchTerm }}">previous</a> {% endif %} <span class="current"> Page {{ projects.number }} of {{ projects.paginator.num_pages }}. </span> {% for i in projects.paginator.page_range %} {% if i == projects.number|add:'-1' … -
comparing form field value with a random object list value inside Django template
I'm trying to build a simple dictionary quiz app . Basically I write the new words and translations , then pick one randomly and ask for its translation.. They get rendered OK in the template but the "if" doesn't work Views.py def QuizRandom(request): choices = list(mydictionary.objects.all()) random_word = random.sample(choices, 1) form = QuizForm() q = '' if 'q' in request.GET: form = QuizForm(request.GET) if form.is_valid(): q = form.cleaned_data['q'] return render ( request, 'quiz.html', {'random_word':random_word, 'form':form, 'q':q,}) forms.py class QuizForm(forms.Form): q = forms.CharField() quizz.html {% for word in random_word %} <h4>guess the translation: {{word.german}}</h4> <h4>translation: {{word.english}}</h4> <h6>form value: {{q}}</h6> <form method='get' class="form-group" id='get-form' > {% csrf_token %} {{form.as_p}} <button type="submit" class="btn btn-success btn-sm " >GO</button> </form> {% if q == word.english %} <h5>correct</h5> {% else %} <h6>wrong</h6> {% endif %} {% endfor %} -
Use Dictionary based values for Chained Dropdown box Django
How to create a dependent/chained dropdown list for rank dropdown box based on the value of type dropdown list by using values in TYPE ,CO_RANK and NOC_RANK dictionaries if type is OC , rank Field would view CO_RANK dictionary values or if type is NOC, rank Field would view NOC_RANK dictionary values class SysUsers(AbstractUser): """ model all SOILDERS """ # Declare Constants Values TYPE = ( ("CO", 'CO'), ('NOC', 'NOC') ) NOC_RANKS = ( ('AC', 'AC'), ('LAC', 'LAC'), ('CPL', 'CPL'), ('SGT', 'SGT'), ('F/SGT', 'F/SGT'), ('WO', 'WO'), ('MWO', 'MWO'), ) CO_RANK = ( ('PLT OFF', 'PLT OFF'), ('FG OFF', 'FG OFF'), ('FLT LT', 'FLT LT'), ('SQN LDR', 'SQN LDR'), ('WG CDR', 'WG CDR'), ('GP CAPT', 'GP CAPT'), ('ACDR', 'ACDR'), ('AVM', 'AVM'), ('AM', 'AM'), ('ACM', 'ACM'), ) STATUS = ( ('Active', 'Active'), ('Deactivated', 'Deactivated') ) service_no = models.CharField(max_length=100, default="None", null=False, unique=True, blank=False) type = models.CharField(max_length=50, null=False, choices=TYPE, blank=False) rank = models.CharField(max_length=50, null=False, choices=ENG_RANK, blank=False) -
Django: make all models user dependent?
I have many models for very different things. Now I have added user authentication with django-allauth. What I want to do is to make all models user dependent. I mean that only the user can see their own model data that they have stored. What is the best way to achieve this? Do I need to add a ForeignKey to each model I have? model.py: class images(models.Model): ... class things(models.Model): ... class devices(models.Model): ... class messages(models.Model): ... #and so on... -
Virtual Environment Django
Whenever I'm trying to run "./scripts/activate.bat" command in my virtual environment directory for a DJANGO Project, i'm getting the following error : '.' is not recognized as an internal or external command, operable program or batch file. HELP ME TO RESOLVE THIS ERROR... -
Dynamically Process Stored Procedure Results With Django
I am attempting to get the results of a stored procedure and populate a model dynamically, or at a minimum, generate a model based off of the result. My intent is to create a reusable function where it should be ambiguous to the data. I will not know the fields being returned, and wish to take what's returned from the stored procedure, get the field names and put to the data in a an object with said field names. How can I dynamically discover the columns in a result set returned from a stored procedure and then create an object to match? -
Websocket with Django channels doesn't work with heroku, drops connection
hello everyone, i made a blog with a chat room , with django channels and its workin locally perfectly, but when i deploy it to heroku using daphne no message(chat) is showing this is the result og heroku logs --tail this is redis configuration in settings.py CHANNEL_LAYERS = { 'default': { 'BACKEND': 'channels_redis.core.RedisChannelLayer', 'CONFIG': { 'hosts': [(os.environ.get('REDIS_HOST', 'localhost'),6379)], }, }, } Procfile web: daphne elearnow.asgi:application --port $PORT --bind 0.0.0.0 -v2 please let me know if i need to add anything else, as i mentioned its stopped showing messages only in production , but locally with the same code everythin is fine i made sure Redis is working, and add "s" for my jquery so its secure "wss://" Thank you very much -
passing the dates between two dates back into the formatday method
I'm learning Python and Django and building a job management app, i have the following which is all working ok and displays the jobs on a html calendar it displays the start and end dates no problem, however if the job is more than two days there is a gap in the calendar as there is no date related to the job to show. i can get the dates in between by doing the following; start = job.start_time end = job.end_time between = end - start for i in range(between.days + 1): datesbetween = [start + timedelta(days=i)] below is my views.py file class AdminCalendarView(LoginRequiredMixin,PermissionRequiredMixin, ListView): model = Job template_name = 'jobs/admin_diary.html' permission_required = 'jobs.add_job', 'raise_exception=True' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) # use today's date for the calendar d = get_date(self.request.GET.get('month', None)) # Instantiate our calendar class with today's year and date cal = AdminCalendar(d.year, d.month) jobs = Job.objects.filter(start_time__year=d.year, start_time__month=d.month) # Call the formatmonth method, which returns our calendar as a table html_cal = cal.formatmonth(jobs, withyear=True) context['calendar'] = mark_safe(html_cal) context['prev_month'] = prev_month(d) context['next_month'] = next_month(d) return context and the utils.py file from datetime import datetime, timedelta, date from calendar import HTMLCalendar from .models import Job from django.db.models import Q class …