Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
- 
        How can i add a page in Pop-Up window in django websiteI want my customers' login pages to open in a pop-up box or window... I have no idea how to do that. The bootstrap template I downloaded has a pop-up video playback option that works well. So I tried editing the href to my login page URL, but when I click on the button it says "127.0.0.1 refused to connect". But the same works when I right-click and open a new window. Maybe it is not the right way to do this... Could anyone help me out? Here is the code for video playback Before <div class="col-lg-6 position-relative align-self-start order-lg-last order-first"> <img src="{% static 'index_assets/img/about.jpg' %}" class="img-fluid" alt=""> <a href="https://www.youtube.com/watch?v=LXb3EKWsInQ" class="glightbox play-btn"></a> </div> And here are the changes I've made Just changed the href After <div class="col-lg-6 position-relative align-self-start order-lg-last order-first"> <img src="{% static 'index_assets/img/about.jpg' %}" class="img-fluid" alt=""> <a href="/login" class="glightbox play-btn"></a> </div>
- 
        How to update User model in Django using signals.pyhow can I update the user model first_name and last_name in Django using signals.py when a new user updates first_name and last_name in custom registration form? This is my signals.py for creating a custom separate user details model using Django @receiver(post_save, sender=settings.AUTH_USER_MODEL) def create_profile_handler(sender, instance, created, **kwargs): if not created: return profile = models.Profile_user(user=instance, first_name=instance.first_name, last_name=instance.last_name, email=instance.email) profile.save() Now I want to update the settings.AUTH_USER_MODEL when an new user update his first_name and last_name using custom register form
- 
        Bash script gives psycopg2 error: symbol not found in flat namespace (_PQbackendPID)?I am using Apple M1. Here is the bash script I wrote. #!/bin/sh # Open Activity Tracker website python -m webbrowser http://127.0.0.1:8000/ # Activate virtual environment . dj-env/bin/activate # Navigate to Activity Tracker project folder cd dj_activity_tracker # Run Django local development server python manage.py runserver When I run these commands on my terminal manually without the script, it works. However, when I use this script, I get the error: File "/Users/doge/Desktop/dj-env/lib/python3.11/site-packages/django/db/backends/postgresql/base.py", line 28, in \<module\> raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Users/doge/Desktop/dj-env/lib/python3.11/site-packages/psycopg2/\_psycopg.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace (\_PQbackendPID) Things I have tried: Uninstall/reinstall psycopg2 brew install postgresql I am stumped on how this is working manually but not when I run the script. What could be the issue? I appreciate your support.
- 
        Django aggregate with joining two tableI am trying to use aggregate with two table Table 1 Sale which is include this field Table 2 saleProduct which has field price and fee Both table has foreign key with field name code I am trying this query to fetch data according to tags sales = Sale.objects.using('read_rep') \ .prefetch_related('sale__product') \ .filter(tags__name__in=['Device','Mobile']).values( 'tags__name' ).annotate( tags_count=Count('tags__name') ).aggregate(price_avg=Avg('price'), total_price=Sum('price')) But it is giving me FieldError: Cannot resolve keyword 'price' into field
- 
        When we deploy our Django app to Heroku it says "changes that are not yet reflected in a migration," but also says it has no migrations to makeMy local repo is up-to-date with my Heroku repo. When I run makemigrations or migrate locally, it says there are no changes. When I run makemigrations on Heroku, it does these exact same changes every time, no matter how many times I run it: python manage.py makemigrations users kits email Migrations for 'kits': apps/kits/migrations/0002_auto_20221209_1204.py - Change Meta options on historicalkit - Alter field history_date on historicalkit Migrations for 'users': apps/users/migrations/0002_auto_20221209_1204.py - Change Meta options on historicaluser - Alter field history_date on historicaluser ...but then if I run migrate on Heroku, it says there is nothing to migrate, AND that there are un-made migrations: python manage.py migrate Operations to perform: Apply all migrations: admin, auth, contenttypes, email, kits, sessions, users Running migrations: No migrations to apply. Your models in app(s): 'kits', 'users' have changes that are not yet reflected in a migration, and so won't be applied. Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them. This is causing our whole web app to go down. What's going on?
- 
        CORS policy blocks XMLHttpRequestWith Ionic Angular running in on my localhost I made this call to my Django backend (running on different localhost): test() { return this.httpClient.get(endpoint + '/test', { headers: { mode: 'no-cors' }, }); } And on the backend side I have following code to respond: @csrf_exempt def test(request): response = json.dumps({'success': True}) return HttpResponse(response, content_type='application/json', headers={'Access-Control-Allow-Origin': '*'}) I have also this in my settings.py file: INSTALLED_APPS = [ ... 'corsheaders', ] MIDDLEWARE = [ ... 'corsheaders.middleware.CorsMiddleware', ] CORS_ALLOW_ALL_ORIGINS = True CORS_ALLOW_CREDENTIALS = True Still, I get this error message in my console: Access to XMLHttpRequest at 'http://127.0.0.1:8000/test' from origin 'http://localhost:8100' has been blocked by CORS policy: Request header field mode is not allowed by Access-Control-Allow-Headers in preflight response. What am I doing wrong? Thank you very much for your help!
- 
        How to set file visibility to other users?Hi im trying to make user upload a file, and then choose to which users this file will be visible .How do i set this one to many relation.This is my models.py file: ` from django.db import models from django.contrib.auth.models import User class UserFile(models.Model): owner = models.ForeignKey(User, on_delete=models.CASCADE) file = models.FileField(upload_to='media/') uploaded = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) trash = models.BooleanField(default=False) favourite = models.BooleanField(default=False) visibilty = models.ManyToManyField(User) ` I tried this but it gives me this error message: managefiles.UserFile.owner: (fields.E304) Reverse accessor 'User.userfile_set' for 'managefiles.UserFile.owner' clashes with reverse accessor for 'managefiles.UserFile.visibility'. HINT: Add or change a related_name argument to the definition for 'managefiles.UserFile.owner' or 'managefiles.UserFile.visibility'. managefiles.UserFile.visibility: (fields.E304) Reverse accessor 'User.userfile_set' for 'managefiles.UserFile.visibility' clashes with reverse accessor for 'managefiles.UserFile.owner'. HINT: Add or change a related_name argument to the definition for 'managefiles.UserFile.visibility' or 'managefiles.UserFile.owner'.
- 
        How to make my SDK file which it serves as a KEY available in my EC2 instance and hide itI have a running django app which when on server does not find my .json file to access my sdk key. Is there a way to make it available just like you do with string variable ? So far I'v tried this : GOOGLE_APPLICATION_CREDENTIALS = '.env_files/service-account-file.json' which it work locally
- 
        Render django template by specific IDI'm trying to create a template that renders each model where the id=pk. However i'm wondering can I link to a specific models in in my HTML template. For example, instead of <a href="{% url 'single-supplier' supplier.id %}" could i write something akin to <a href="{% url 'single-supplier' supplier.id=1 %}" The reason i ask this is that I wish to link to a specific id in my navigation bar ` {% load static %} <header> <div class="container"> <!-- Navbar --> <nav id="navbar" class="{% if request.resolver_match.url_name == 'home' %} main-page {% endif %}"> <a href="{% url 'home' %}"><img src="{% static 'images/farmeclogo.png' %}" alt="Logo" id="logo"></a> <ul class="nav-list"> <li class="nav-list-item"><a href="{% url 'home' %}" class="{% if request.resolver_match.url_name == 'home' %} current {% endif %}">Home</a> </li> <li class="nav-list-item"><a href="{% url 'about' %}" class="{% if request.resolver_match.url_name == 'about' %} current {% endif %}">About</a> <ul class="nav-drop"> <li><a href="{% url 'about' %}">Our Team</a></li> <li><a href="{% url 'about' %}">Our Story</a></li> </ul> </li> <li class=" nav-list-item"><a href="{% url 'suppliers' %}" class="{% if request.resolver_match.url_name == 'suppliers' %} current {% endif %}">Suppliers</a> <ul class="nav-drop"> <li> <a href="{% url 'single-supplier' supplier.id %}">SIP Grass Machinery</a> </li> <li> <a href="#">MX Loaders & Front-Linkage</a> </li> <li> <a href="#">Sulky Fertilizer, Harrows & Drills</a> </li> </ul> </li> …
- 
        Django - how to set up a cache in Django template displayI have a queryset which is students and their number: A 2, B 2. Another queryset is teachers and their number: C 2, D 3, E 2. I want to match students and teachers based on their number on the HTML page, and if student A is matched with teacher C already, he won't be with matched with another teacher. It doesn't matter which students matches with which teacher as long as they have a matched number. Something like this: C 2 A D 3 E 2 B The best I can think of is something is like this (of course this code won't work): {% with covered_students = [] %} {% for teacher in teachers %} {{ teacher.name }} {{ teacher.number }} {% for student in students %} {% if student.number == teacher.number and student.name not in covered_students %} {{ student.name }} {% covered_students.append(student.name) %} {% endif %} {% endfor %} {% endfor %} {% endwith %} Thanks in advance!!!
- 
        Django helper function to rename user uploaded imageFor a django project I have a model that features an image field. The idea is that the user uploads an image and django renames it according to a chosen pattern before storing it in the media folder. To achieve that I have created a helper class in a separate file utils.py. The class will callable within the upload_to parameter of the django ImageField model. Images should be renamed by concatenating .name and .id properties of the created item. The problem with my solution is that if the image is uploaded upon creating anew the item object, then there is no .id value to use (just yet). So instead of having let's say: banana_12.jpg I get banana_None.jpg. If instead I upload an image on an already existing item object, then the image is renamed correctly. Here is my solution. How can I improve the code to make it work on new item object too? Is there a better way to do this? # utils.py from django.utils.deconstruct import deconstructible import os @deconstructible class RenameImage(object): """Renames a given image according to pattern""" def __call__(self, instance, filename): """Sets the name of an uploaded image""" self.name, self.extension = os.path.splitext(filename) self.folder = instance.__class__.__name__.lower() image_name = …
- 
        how configuration, connect media-directory of django to Capanel host managment?I want calling pictures or video from media uploaded from users in django project. as well as i want upload piuctures from user and calling in blogs book app. I try this but not work it for me: MEDIA_ROOT = 'home/username/public_html/media
- 
        How to create React JS SliderSlider component in react. Our slider component is going to be composed of two parts. Slider area where slides will be sliding. Navigation control to change the slides. Let us begin our development by importing all the required packages at the top import React, { Component } from "react"; import styles from "./index.module.css"; import { Transition, animated } from "react-spring/renderprops"; class Carousel extends Component { //Other code will go here } export default Carousel; Check with error.
- 
        Django CoInitialize has not been calledI am trying to automate outlook, using python Django. the code works pretty good directly using python, but when using it in my Django app it gives me this error. > pywintypes.com_error: (-2147221008, 'CoInitialize has not been called.', None, None) and my views code is : import win32com.client as win32 def about(request): olApp = win32.Dispatch('Outlook.Application') olNS = olApp.GetNameSpace('MAPI') inbox = olNS.GetDefaultFolder(6) messages = inbox.Items for msg in messages: if msg.Class==43: if msg.SenderEmailType=='EX': print(1,msg.Sender.GetExchangeUser().PrimarySmtpAddress) else: print(2, msg.SenderEmailAddress) return render(request,'Home/About.html') So any suggestion to solve this problem?
- 
        Make Inline panel on Django with wagtailI'm making a pizzeria website and I want to have a few more sizes in the size like dropdown menu, for example 36cm and 40, how can I do this? Im using wagtail 4.1.1 and django 4.1.4 My models.py: class Product(Page): size = models.CharField(max_length=20, null=True) sku = models.CharField(max_length=255) short_description = models.TextField(blank=True, null=True) price = models.DecimalField(decimal_places=2, max_digits=10) image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+' ) content_panels = Page.content_panels + [ FieldPanel('sku'), FieldPanel('price'), ImageChooserPanel('image'), FieldPanel('size'), FieldPanel('short_description'), InlinePanel('custom_fields', label='Custom fields'), ] def get_context(self, request): context = super().get_context(request) fields = [] for f in self.custom_fields.get_object_list(): if f.options: f.options_array = f.options.split('|') fields.append(f) else: fields.append(f) context['custom_fields'] = fields return context my admin panel looks like this and my product page: Im trying change from FieldPanel('price') to InlinePanel('price'), but i have a error: AttributeError: 'DeferredAttribute' object has no attribute 'rel'
- 
        Python manage.py dumpdata killed prematurelyI'm migrating a database from MySQL to Postgres. This question has been very helpful. When running the python manage.py dumpdata --exclude contenttypes --indent=4 --natural-foreign > everything_else.json to create a json fixture the connection is aborted by the database server. All other steps have been successful. The MySQL database is hosted on RDS and the connection is aborted at the same point in the file each time I try to run this. Logs from the RDS instance state the problem as follows (db, user and host changed): [Note] Aborted connection 600000 to db: 'mydb' user: 'myUsername' host: '127.0.0.1' (Got an error writing communication packets) In the terminal the message is simply killed. Why would this error be happening and how can I create this json fixture?
- 
        Even if i serve media files with nginx, they don't appear on the websiteI am trying to use nginx to put my django app on production. But I cannot use images in the website even though I configured nginx. My nginx server's setup: server { server_name example.com www.example.com; location /static/ { root /home/myusername/myproject/static/; } location /media/ { root /home/myusername/myproject/media/; } location / { proxy_pass http://127.0.0.1:8000; } } My html file: {% extends 'base.html' %} {% block content %} <div class="column"> {% for dweet in dweets %} <div class="box"> {{dweet.body}} <span class="is-small has-text-grey-light"> ({{ dweet.created_at }} από {{ dweet.user.username }}) </span> <figure> <img class="is-rounded" src="/media/{{dweet.image}}" alt="connect" style="max-height:300px"> </figure> </div> {% endfor %} </div> {% endblock content %} I have played around with directory paths, but still nothing.
- 
        Differentiate which button was used to submit form Django/JSI have a Django view of a form that presents the user with two options. On form submission, one Button will send them to one view, the other will send them to another. This is the part of that view: form = MenuItemForm(request.POST or None, request.FILES or None) if request.method != 'POST': # No data submitted; create a blank form. form = MenuItemForm() else: if 'add_ingredients' in request.POST: # POST data submitted; process data. if form.is_valid(): menu_item = form.save(commit=False) menu_item.menu = menu_instance menu_item.save() return redirect('core:add_ingredient', menu_item_id=menu_item.id) else: # POST data submitted; process data. if form.is_valid(): menu_item = form.save(commit=False) menu_item.menu = menu_instance menu_item.save() return redirect('core:edit_menu') This worked fine on its own. Here are the form and buttons in the template: <form id="form" class="form" method="post" action="{% url 'core:add_ingredient' menu_item.id %}"> {% csrf_token %} {{ form.as_p }} <div class="button-container"> <button id="another-ingredient-button" type="submit" name="add_ingredient">Add Another Ingredient</button> <button type="submit" name="substitute">Add Substitute</button> <button class="done" type="submit" name="done">Done</button> </div> </form> After I added the code below, the form still submits, but it doesnt recognize which button was clicked that submitted the form, and always sends me to one view, I thought about adding an eventListener to each button but then the my alert box and the other code …
- 
        How to load a PDF passed by Django to Angular?In Django I have this function that returns a pdf to me def get(self, request): with open(filepath, 'rb') as f: pdf = f.read() return HttpResponse(pdf, content_type='application/pdf') In Angular i have this.http.get(apiUrl, { responseType: 'arraybuffer' }).subscribe( response => { // Create a blob object that represents the PDF file var blob = new Blob([response], { type: 'application/pdf' }); // Create an object URL that points to the blob var objectURL = URL.createObjectURL(blob); // Use the object URL as the src attribute for an <iframe> element // to display the PDF file document.getElementById('iframe').src = objectURL; }, error => { console.log(error) } ); In the <iframe> I get "Unable to upload PDF document" What am i doing wrong?
- 
        How fix this error : exchangelib.errors.InvalidTypeError: 'tzinfo' <UTC> must be of type <class 'exchangelib.ewsdatetime.EWSTimeZone'>In my Django project, I have bump the Exchangelib version (3.2.1 to 4.9.0) and now an error occurs. Traceback : File "/home/.../workspace/my_project/exchange_manager/models.py", line 297, in create_event event = self.create(*args, **kwargs) File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/models/query.py", line 453, in create obj.save(force_insert=True, using=self.db) File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/models/base.py", line 726, in save self.save_base(using=using, force_insert=force_insert, File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/models/base.py", line 763, in save_base updated = self._save_table( File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/models/base.py", line 868, in _save_table results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw) File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/models/base.py", line 906, in _do_insert return manager._insert( File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/models/query.py", line 1270, in _insert return query.get_compiler(using=using).execute_sql(returning_fields) File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1409, in execute_sql for sql, params in self.as_sql(): File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1352, in as_sql value_rows = [ File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1353, in <listcomp> [self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields] File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1353, in <listcomp> [self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields] File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1294, in prepare_value value = field.get_db_prep_save(value, connection=self.connection) File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 842, in get_db_prep_save return self.get_db_prep_value(value, connection=connection, prepared=False) File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 1428, in get_db_prep_value return connection.ops.adapt_datetimefield_value(value) File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/db/backends/sqlite3/operations.py", line 247, in adapt_datetimefield_value value = timezone.make_naive(value, self.connection.timezone) File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/django/utils/timezone.py", line 256, in make_naive return value.astimezone(timezone).replace(tzinfo=None) File "/home/.../.local/share/virtualenvs/my_project-iOt348t5/lib/python3.8/site-packages/exchangelib/ewsdatetime.py", line 128, …
- 
        How can I make user is authenticated?Sorry, I dont know how to change syntax in stackowerflow and decided just put link to repository for you: https://github.com/ilya-6370/todo-react The folder backend/todo is main folder with settings,py and main file scheme.py The folder backemd/todoapp is the folder with details of app and api for todos in scheme.py the folder frontend is the folder with react app where i am using apolo client to make request and to add custom header When I am trying to fetch todos I get permission error: {"errors":[{"message":"You do not have permission to perform this action","locations":[{"line":2,"column":3}],"path":["todos"]}],"data":{"todos":null}} headers: request headers : accept: */* Accept-Encoding: gzip, deflate, br Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7 authorisation: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InVzZXIiLCJleHAiOjE2NzA1MzgwNzIsIm9yaWdJYXQiOjE2NzA1Mzc3NzJ9.eGl0oI2x7kYeuhRyryhUdcLyNgnvXuUSRsBJu6_iHFY Connection: keep-alive Content-Length: 111 content-type: application/json Host: 127.0.0.1:8000 Origin: http://localhost:3000 Referer: http://localhost:3000/ sec-ch-ua: "Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108" sec-ch-ua-mobile: ?0 sec-ch-ua-platform: "Windows" Sec-Fetch-Dest: empty Sec-Fetch-Mode: cors Sec-Fetch-Site: cross-site User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 I have a custom field "authorisation" with token. How I can make user authorased for system by jwt token (I think it is my problem because I made authontication requiered fields in my scheme.py file in todoapp folder. I think that token does not give authonticated status, I need a way to make user …
- 
        chown(): Operation not permitted occurred due to chown-soket of uwsgi【nginx】I tried to run a django program using nginx and uwsgi, but the following error occurs in nginx. connect() to unix:/var/www/html/view/dbproject/dbproject.sock failed (13: Permission denied) while connecting to upstream I thought this error was probably because the owner of dbproject.sock, which is created when uwsgi is started, is username:username and not username:www-data. Therefore, I added chown-soket = %(username):www-data in the uwsgi initialization file uwsgi.ini, but when I restart uwsgi, chown(): Operation not permitted is written in the uwsgi log. How can I make the socket owner %(username):www-data? Thank you. uwsgi.ini [uwsgi] # path to your project chdir = /var/www/html/view/dbproject username = myusername # path to wsgi.py in project module = dbproject.wsgi:application master = true pidfile = /var/www/html/view/dbproject/django.uwsgi.pid socket = /var/www/html/view/dbproject/dbproject.sock # http = 127.0.0.1:8000 # path to python virtualvenv home = /var/www/html/view/myvenv chown-socket = %(username):www-data chmod-socket = 660 enable-threads = true processes = 5 thunder-lock = true max-requests = 5000 # clear environment on exit vacuum = true daemonize = /var/www/html/view/dbproject/django.uwsgi.log # Django settings env DJANGO_SETTINGS_MODULE = dbproject.settings
- 
        django queryset filter on whether related field is emptyhere is my models: class Flag(models.Model): ban = models.ForeignKey('flags.Ban', on_delete=models.CASCADE, related_name='flags') class Ban(models.Model): punished = models.BooleanField(default=None) Flag is triggered when user report some content. and they are summarised in to a Ban instance for administrator to verify. briefly, a ban can have many flags. there is one occasion, that the author getting reported, manually deletes the content he/she has sent before admin heads over there. the ban should be dismissed. therefore. in ban list view, I try to filter them out and delete. to_deletes = [] for ban in Ban.objects.all(): if not len(ban.flags.all()): to_deletes.append(ban) for ban in to_deletes: ban.delete() I wonder if there is a way I can write this into a queryset, all I need is a Ban.objects.all() that rejected empty flags for list view for performance and elegancy.
- 
        AttributeError at /check 'QuerySet' object has no attribute 'name'i wanted to check whether the name is exists in owner table or not. this is my index.html ` <form style="color:black" method="POST" action="check" class=" mt-3"> {% csrf_token %} <div class="row mb-3"> <label for="inputText" class="col-sm-3 col-form-label">Username</label> <div class="col-sm-8"> <input type="text" name="name" placeholder="Username" class="form-control"> </div> </div> <div class="row mb-3"> <label for="inputText" class="col-sm-3 col-form-label">Password</label> <div class="col-sm-8"> <input type="text" name="password" placeholder="password" class="form-control"> </div> </div> <button class="btn btn-success mb-3" type="submit">Login</button> <a class="btn btn-danger mb-3" href="index">Go Back</a> </form> this is my urls.py path('index', views.index), path('check', views.check), this is my views.py def check(request): owners = owner.objects.all() if request.method == "POST": name = request.POST.get('name') password = request.POST.get('password') if owners.name == name and owners.password == password : return render(request, "card/check.html") it gives error on this line if owners.name == name and owners.password == password : ` how to check whether the name exist or not in table
- 
        How can i add paginator to Django filterHow can I add a paginator to the Django filter? I tried to add but whenever I am creating I got an error sometimes when the user chooses to filter by category paginator will not work all the content will show for eg: If I give paginate_by = 25 and when the user selects filter by category more than 25 data will be shown. when the paginators work filtering does not work These is my views.py class blogview(ListView): model = wallpapers template_name = 'blogs/blog.html' context_object_name = 'blogs' ordering = '-created_on', '-time' paginate_by = 2 def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['filter']=WallpaperFilter(self.request.GET, queryset=self.get_queryset()) return context I am trying to add paginator to these function