Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django read excel (xlsx) file to display in a table
I have a simple excel file I am trying to figure out how I can get my app to read the excel file, so I can use the data to display in a template. I have looked into xlrd but does anyone have any suggestions on the best way to do this? -
Attaching VS Code to a dockerized django app and running the debugger, where are the docker logs?
I have a dockerized django app which I work on with VS Code. I start the container, then attach to it using VS Code's remote attach. Then I start the debugger on port 7000 with the following launch file. I run the code that crashes things, but its a silent failure in the Terminal / Output / Debug Console. I inspect the docker logs but I only see output from the program running on port 8000. How do I see the stack trace (or docker logs) for the code running on port 7000? -
How do I use Apache Guacamole with Django for a Web Application? (Without using Default Client)
I'm currently working on a project which involves using Apache Guacamole to make remote connections to other devices in a network. I am using Django and its REST Framework purely to serve as the backend for my web application (Front-end hosted elsewhere). I do not want to use the default Guacamole client and would like to just implement its remote connection capability into my own web application. My question is, is there a standard way to achieve this using Django? If not, how would I go about integrating remote desktop access using Apache Guacamole with Django to allow users of my web application to remotely access machines? P.S. I am familiar with how to use the prepackaged Guacamole Client supplied. I have also looked into solutions to my issues such as: https://github.com/jimmy201602/django-guacamole/tree/master/guacamole (Fork because original repository has been deleted). However, I am facing an issue with this code where the remote desktop connection is successfully established (user on computer kicked out), there is no display of the remote desktop shown (just a white screen). -
How to automatically get Model Field type, its properties and size from other apps?
I am developing API in DRF. Django : 3.2.3 djangorestframework : 3.12.4 In my master_details App I've created a model with different fields. Some are mentioned bellow class MasterModel(models.Model): name = models.CharField(max_length=100, null=False, blank=True) address = models.TextField(null=False, blank=True) data = models.DecimalField(max_digits=5, decimal_places=2) ... Similarly I have a report App which provide Get API endpoint to reporting tools. This report model shall contain certain fields that are same as/imported from MasterModel as shown bellow class ReportModel(models.Model): name = models.CharField(max_length=100, null=False, blank=True) address = models.TextField(null=False, blank=True) data = models.DecimalField(max_digits=5, decimal_places=2) ... or class ReportModel(models.Model): name = models.ForeignKey(MasterModel, on_delete=models.CASCADE) address = models.ForeignKey(MasterModel, on_delete=models.CASCADE) data = models.ForeignKey(MasterModel, on_delete=models.CASCADE) ... I am unable to use Foreign Key, in case data in MasterModel changes it will propagate to ReportModel. This should be avoided as historical reports must not be affected and the integrity of historical records must be maintained. I have manually duplicated the fields in the ReportModel and I manually maintain their congruence. I wish to get around this. I wish to know is their any automatic way whereby I can create Model Field type and apply its properties and size from other apps? -
How do I create a prepopulated model field in django to view in admin panel?
I have a model in models.py: class Package(models.Model): diagnosis=models.ForeignKey(Diagnosis, on_delete=CASCADE) treatment=ForeignKey(Treatment, on_delete=CASCADE) patient_type=ForeignKey(PatientType, on_delete=CASCADE) max_fractions=models.IntegerField(default=max_fractions) total_package=models.FloatField(max_length=10, default=total_package) rt_number=ForeignKey(Patient, on_delete=CASCADE) I want the fields, max_fractions and total_package, to be prepopulated with the values returned by their respective default parameters. The functions: def max_fractions(): if Treatment.treatment=='3DCRT' and PatientType.patient_type=='MJPJAY': return 30 if Treatment.treatment=='3DCRT' and PatientType.patient_type=='PMJAY': return 30 def total_package(): if Treatment.treatment=='3DCRT' and PatientType.patient_type=='MJPJAY': return float(75000) if Treatment.treatment=='3DCRT' and PatientType.patient_type=='PMJAY': return float(70000) But I get: What am I missing? -
when I instaling django with pipenv which approch is better?
when installing pakages and other things in project like django declaring version is good or bad? pipenv install django or pipenv install django==3.1.0 -
Raise AttributeError(f"Use item[{name!r}] = {value!r} to set field value") in Django
we are following a tutorial for connecting Scrapy with Django. This is our model.py file: class Siteinformation(models.Model): unique_id = models.CharField(max_length=100, null=True) data = models.CharField(max_length=1000, null=True) timestamp = models.DateTimeField(default=timezone.now) @property def to_dict(self): data = { 'data': json.loads(self.data), 'timestamp': self.timestamp } return data def __str__(self): return self.unique_id This is the pipelines.py file: class ShopspiderappPipeline(object): def __init__(self, unique_id, *args, **kwargs): self.unique_id = unique_id self.items = [] @classmethod def from_crawler(cls, crawler): return cls( unique_id=crawler.settings.get('unique_id'), ) def close_spider(self, spider): item = Siteinformation() item.unique_id = self.unique_id item.data = json.dumps(self.items) item.save() def process_item(self, item, spider): self.items.append(item['url']) return item This is the spider.py file: class ShopSpider(CrawlSpider): name = 'shop' def __init__(self, *args, **kwargs): self.url = kwargs.get('url') self.domain = kwargs.get('domain') self.start_urls = [self.url] self.allowed_domains = [self.domain] ShopSpider.rules = [ Rule(LinkExtractor(unique=True), callback='parse_item'), ] super(ShopSpider, self).__init__(*args, **kwargs) def parse_item(self, response): item = Siteinformation() item = {} item['url'] = response.url yield item Unfortunately it produces this error: 2021-06-29 17:17:45 [scrapy.core.engine] ERROR: Scraper close failure Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/twisted/internet/defer.py", line 662, in _runCallbacks current.result = callback(current.result, *args, **kw) File "/Users/.../.../..../shopspiderapp/shopspiderapp/pipelines.py", line 31, in close_spider item.unique_id = self.unique_id File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/scrapy/item.py", line 112, in __setattr__ raise AttributeError(f"Use item[{name!r}] = {value!r} to set field value") AttributeError: Use item['unique_id'] = '0a55d509-bd36-49ba-b3c8-313fbadcd3de' to set field … -
Best way to handle Django Migrations with Git?
Maybe this has been asked, but, at least from the ones i've readed, i'm not convinced. The idea is that i'm on a project with multiple people working on the backend, and because people are assigned to solve different issues, each one make their own changes on the models, and that implies each one can have their own migrations, which might clash either by just having the same numbered migration as to make changes to the same tables. As a way to work with this, we devised a solution in which we create 3 branches: Master, QA and Develop, the first one is the one at production, Develop is the one where changes to test on our development server will be merged to test, and QA as an intermediate between the 2, the idea is that we will be working the changes on new branches(feature/xxxxxx) with their respective migrations, and when we need to upload to the developmente server, we will merge to develop, which will handle migration conflicts, and then, when the change is approved, we will delete the migrations of the new branch(feature/xxxxxx), merge it to QA, and delete that branch, and once QA is ready to be … -
Django show all objects and foreach object all compatible objects
I am new to Django and I want to create a compatibility model for mobile phone. I create a model with all phone details like name, screen size etc. and I thought of creating a new model for compatibility. The first model in Django class MobilePhone(models.Model): name = models.CharField(max_length=500) manufacturer = models.ForeignKey(MobileManufacturer, on_delete=models.PROTECT) dimensions = models.TextField(max_length=500, null=True, blank=True) display_type = models.CharField(max_length=500, null=True, blank=True) display_size = models.CharField(max_length=500, null=True, blank=True) and another model for compatibility class Compatibility(models.Model): comp_id = models.CharField(max_length=30) comp_type = models.CharField(max_length=30) mobile_id = models.ForeignKey('MobilePhone', on_delete=models.CASCADE) I fill the MobilePhone table with values id name manufacturer dimensions 1 Phone 1 Samsung 8x15 2 Phone 2 Samsung 8x15 3 Phone 3 Samsung 8x15 4 Phone 4 Samsung 8x15 and the Compatibility table with id comp_id comp_type mobile_id 1 100 screen 1 2 100 screen 2 3 101 screen 3 4 100 screen 4 the comp_id is the unique number I use to group the phones now with all_entries = MobilePhone.objects.all() get all mobile phones like - Phone 1 - Phone 2 - Phone 3 - Phone 4 what I want is - Phone 1 -- (same with Phone 2, Phone 4) - Phone 2 -- (same with Phone 1, Phone 4) - … -
Create dynamic amount of form-fields in HTML and extract them from request (Django)
I have a view which does the following: Scrape som prices from a product-page. Return a HTML page with a picture of each product incl. the price (like a check-out cart from a webshop) If the price is incorrect, the user should then be able to modify the price for each product, and atlast click one button, which then saves the products. Right now I have my view #views.py def my_products(request): user = request.user if request.method == "POST": form = MyForm(request.POST) if form.is_valid(): domain = form.cleaned_data["domain"] discount_pct = form.cleaned_data["discount_pct"] link = form.cleaned_data["link"] #Extract info for each link prices,links,images,errors = scrape_pagee(domain,link) context = { "data":zip(prices,links,images)} return render(request, "myapp/list_confirm.html",context=context) else: add_form = MyForm() context = { "add_form":add_form, } return render(request, "myapp/add_list.html",context=context) where prices, links are array of the given prices and the link to each product e.g prices = [600,200,159], links = ["www.webshop1.com/shirt","www.webshop2.com/jeans","www.webshop1.com/socks"] I think parsing the forms isn't a problem (I assume it is just parsing an array of Forms to the context and loop over them in the HTML page), but it's more how to submit them all in one "save" button, and how to distinguish them from eachother in the POST-request. -
I'm Fetching Audio File Via Ajax from Server for Search Function But Not Audio Playing After Render Player
Below is My Django CMS Code for Fetching Music Ringtone from Server [Database], Code Fetch Music Ringtones from Server Successfully But After Render Player With Ringtone Not Playing Audio. "Backend Code " def search_ringtone(request): data = {} for key, _ in request.GET.items(): data = json.loads(key) query = data.get("query", None) if query: ringtone_objects = Ringtone.objects.filter(name__icontains=query) ringtones = [] for item in ringtone_objects: ringtone_file = item.android_ringtone_file if item.android_ringtone_file else item.iphone_ringtone_file ringtones.append( { "category_public_url": item.category.page.get_public_url(), "category_name": item.category.name, "ringtone_url": item.page.get_public_url(), "ringtone_media_url": ringtone_file.url, "ringtone_type": "audio/mpeg" if item.android_ringtone_file else "audio/audio/x-m4r", "ringtone_name": item.name, "ringtone_download_count": item.download_count, } ) return JsonResponse({"result": True, "ringtone": ringtones, "query":query}) return JsonResponse({"result": False}) Player Function $(".ringtone-player .play-btn .fa-play-circle").on('click', function(current) { $(this).parent().find(".fa-play-circle").css("display", "none"); $(this).parent().find(".fa-snowflake-o").css("display", "inline-block"); $(".fa-play-circle").not(this).parent().find(".fa-snowflake-o").css("display", "none"); $(".fa-play-circle").not(this).parent().find(".fa-play-circle").css("display", "inline-block"); // ADD / REMOVE CLASS $(this).parent().parent().addClass("isPlaying"); $(".fa-play-circle").not(this).parent().parent().removeClass("isPlaying"); // ani $(this).parent().parent().find(".beat_animation ul li").css("animation-play-state", "running").css("opacity", "1"); $(".fa-play-circle").not(this).parent().parent().find(".beat_animation ul li").css("animation-play-state", "paused").css("opacity", ".1"); // PASUE CURRENT AUDIO TRACK WHEN PLAY NEXT/PREV AUDIO TRACK $("audio").each(function(e) { if (e !== current.currentTarget) { $(this)[0].pause(); } }); // PLAY CURRENT AUDIO TRACK $(this).parent().parent().find(".track audio")[0].play(); }); // PAUSE FUNCTION $(".ringtone-player .play-btn .fa-snowflake-o").on('click', function() { // HIDE PASE ICON $(this).parent().find(".fa-snowflake-o").css("display", "none"); // Show Play Icon $(this).parent().find(".fa-play-circle").css("display", "inline-block"); // PAUSE AUDIO TRACK $(this).parent().parent().find(".track audio")[0].pause(); }); $(audio).on('ended', function() { // HIDE PASE ICON $(".ringtone-player .play-btn .fa-snowflake-o").css("display", "none"); // … -
Python get time at specify GMT
I am trying to get the current time at a specific GMT ( like +3 -1 etc.). I have a script that runs on a remote server, and he needs to update the current time at another country which I can not find at the time_zone list. I tried import pytz pytz.all_timezones And look for the country and find it in the list; I know the county GMT is +3. import datetime from django.utils.timezone import now both now function is relevant to me, and I can not find how I find the now function with GMT +3 -
How to add ArrayField in Django?
my models.py class LiveClass_details(models.Model): standard = models.ForeignKey(LiveClass, on_delete=models.CASCADE) chapter_details = models.TextField(default='') mentor_id = models.ForeignKey(Mentor, max_length=30, on_delete=models.CASCADE) start_time = models.DateTimeField() end_time = models.DateTimeField() doubtClass = models.OneToOneField(DoubtClasses, on_delete=models.PROTECT, null=True, blank=True) isDraft = models.BooleanField(default=True) ratings = models.FloatField(default=0) no_of_students_registered = models.IntegerField(default=0) # registered_students = models.ManyToManyField(RegisteredNames, null=True, blank=True) no_of_students_attended = models.IntegerField(default=0) class Meta: verbose_name_plural = 'LiveClass_details' class RegisteredNames(models.Model): name = models.CharField(max_length=100, unique=True) liveclass_id = models.ForeignKey I am creating a endpoint where when a user register himself his name will get added to registered_students , so i had made a registered students ManyToMany Field hoping it will get updated when a user is registered but then i understand that it will contain all the names that are present in the RegisteredNames Model meaning names registered across all the liveclasses but i want only the names that are registered for a particular liveclass in the field so i need a array like field which i think is not possible so please help me in improving my logic, how can i achieve it -
Django reset password and verification with email using function based view
Django reset password and verification with email using function based view. -
App is Not showing up in Django 3.0 admin
I have put my app in the settings.py: 'jet', 'jet.dashboard', 'store.apps.StoreConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'tinymce', ] no error is there. I suspect the admin.py of my app: from django.contrib import admin from .models import Customer, Product, Order, OrderItem, Shipping, models from tinymce.widgets import TinyMCE class ProductAdmin(admin.ModelAdmin): formfield_overrides = { models.TextField: {"widget": TinyMCE()} } admin.register(Customer) admin.register(Product, ProductAdmin) admin.register(Order) admin.register(OrderItem) admin.register(Shipping) But the models are registered properly, and no error is there. I have use Django-3-jet module to customise my admin page. Help Will Be appreciated. App name: store. -
nginx 502 bad gateway, location of nginx.config
I am trying to upload my app to AWS (Python 3.8 running on 64bit Amazon Linux 2) through Elastic Beanstalk. My app has been developed with Django 3.0. OS is Ubuntu 20.04. I start with an empty Django project, this works fine with a green status health check, and Django admin works fine. When I add files from my app it throws the 502 bad gateway error. I have spent many days trying to fix this with no luck. var/log/nginx/error/log: 2021/06/29 15:29:42 [error] 4854#4854: *4084 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.20.250, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "35.176.238.136" django.config option_settings: aws:elasticbeanstalk:container:python: WSGIPath: FFfF_project.wsgi:application aws:elasticbeanstalk:environment:proxy:staticfiles: /static: static aws:elasticbeanstalk:application:environment: DJANGO_SETTINGS_MODULE: FFfF_project.settings PYTHONPATH: "/var/app/current:" 01_packages.config packages: yum: python3-devel: [] mariadb-devel: [] requirements.txt django==3.0 django-crispy-forms==1.9.2 Pillow==8.2.0 gunicorn==20.0.4 mysqlclient==1.4.6 config.yml branch-defaults: master: environment: FFfF-env group_suffix: null environment-defaults: FFfF-env: branch: null repository: null global: application_name: FFfF_project branch: null default_ec2_keyname: ff-KeyPair default_platform: Python 3.8 running on 64bit Amazon Linux 2 default_region: eu-west-2 include_git_submodules: true instance_profile: null platform_name: null platform_version: null profile: eb-cli repository: null sc: git workspace_type: Application I think the error is related to the nginx.config file, but I cannot find this file to either edit or modify. … -
Using D3.js to pick and choose data out of SQLite3 database
I am pretty new to coding and am trying to build a web app that is able to visualize Data out of a SQLite3 database. Is it possible to pick individual datapoints out of a 30k row database to visualize it as a stacked bar chart? I would like to build a search field where its possible to search for the datapoints. And idealy have an update field to update the visualization after picking the datapoints. Many Thanks in Advance -
Issue using progress_recorder (celery-progress): extends time of task
I want to use celery-progress to display progress bar when downloading csv files my task loop over list of cvs files, open each files, filtered data and produce a zip folder with csv filtered files (see code below) but depending where set_progress is called, task will take much more time if I count (and set_progress) for files processed, it is quite fast even for files with 100000 records but if I count for records in files, that would be more informative for user, it extends time by 20 I do not understand why how can I manage this issue for file in listOfFiles: # 1 - count for files processed i += 1 progress_recorder.set_progress(i,numberOfFilesToProcess, description='Export in progess...') records = [] with open(import_path + file, newline='', encoding="utf8") as csvfile: spamreader = csv.reader(csvfile, delimiter=',', quotechar='|') csv_headings = ','.join(next(spamreader)) for row in spamreader: # 2 - count for records in each files processed (files with 100000 records) # i += 1 # progress_recorder.set_progress(i,100000, description='Export in progess...') site = [row[0][positions[0]:positions[1]]] filtered_site = filter(lambda x: filter_records(x,sites),site) for site in filtered_site: records.append(','.join(row)) -
Django Form Widgets SyntaxError: cannot assign to function call
I'm trying form widgets and I coded this class in my forms.py: class RawProductForm(forms.Form): title = forms.CharField(label='', widget=forms.TextInput(attrs={"placeholder: "Your title"})) description = forms.CharField( required= False, widget=forms.Textarea( attrs={ "class": "new-class-name two", "id": "my-id-for-textarea", "rows": 100, "cols": 20 } ) ) price = forms.DecimalField(initial=199.99) But I'm getting an error which I do not know how to solve: line 16 title = forms.CharField(label='', widget=forms.TextInput(attrs={"placeholder: "Your title"})) ^ SyntaxError: expression cannot contain assignment, perhaps you meant "=="? -
Is there a tool that syncs two parts of a code base so that updating one automatically updates the other?
I'm looking for a vim, vscode, or emacs tool/plugin that allows you two define a link two parts of the same codebase (same or different files), such that they stay synced up. If you update one of them, the other is updated to match it automatically. An example is with a Django project below. On the left (line 12) is a view called detail with a docstring that contains the url endpoint that calls that view. On the right (line 8) is the code that links that url to that function. The url endpoint is place/<int:place_id>/. If I update the url on the left or on the right to place/<int:place_id/asdf, the other one should update automatically. (This can occur live, or whenever the file is saved). Do you know of any tool that can do this live syncing of specific parts of code files? -
Migrating a Python package in Django on Heroku?
I'm working on a Django project, and I installed a Python package using pip (specifically the django-gsheets package). This package has its own set of migrations contained in its own package files (/env/lib/python3.7/gsheets/migrations/), and when I run python manage.py migrate, Django finds them and applies them, even though they're not in my project directory. However, I run into problems with doing it remotely on the Heroku server. I've added the package to my requirements.txt and 'gsheets' (the app name) to INSTALLED_APPS in settings.py, but when I do heroku run python manage.py migrate, it can't find the migrations. I tried manually adding a 'gsheets' folder in the root directory of my project, with its own 'migrations' folder, copying over the migrations into it, committing, and pushing to Heroku, but Heroku still can't find the migrations. I've also tried heroku run python manage.py makemigrations, which does make the right migrations on the Heroku server, but Heroku can't find these when I tried to run the migration. It's starting to feel like I might have to just copy the entire gsheets project into my root project directory in order to actually use it on Heroku, but I'm wondering if there are any better … -
Retrieving the true size of a html document
I have a html document that I created using googles "site" service. I tried exporting and embedding this document into my django website by including it into one of my templates. However, the content of my website overlaps with the footer, since apparently the html engine doesn't recognize the actual size of the embedded document and starts placing elements before it has actually ended. Editing the document itself is impossible because it's just a large block of unstructured code. I can solve the problem by adding break tags at the end of the document and seeing how many I need to get the footer to the correct height again, but I would like to be able to reedit this site and don't want to keep calculating how many tags i need each time. The recognized size is always the same, however long the document itself actually becomes. The file itself is too large to paste into pastebin but contains too many elements to properly navigate. Is there a good way to still embed this document into a regular html document without requiring the use of additional code? -
"non_field_errors" upon loging in using Django Rest Framework and Knox
I looked through all the relevant threads I could find and nothing seems to work. When I try to login through the API, it shows the 'non_field_errors' (username and password are correct). Here's my views.py, serializers.py and settings.py: views.py: class LoginAPI(generics.GenericAPIView): serializer_class = LoginUserSerializer permissions_classes = () queryset = User.objects.all() def post(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) user = serializer.validated_data return Response({ "user": UserSerializer(user, context=self.get_serializer_context()).data, "token": AuthToken.objects.create(user)[1] }) def get(self, request, *args, **kwargs): user = User.objects.all() serializer = UserSerializer(user, many=True) return Response(serializer.data) serializers.py: class LoginUserSerializer(serializers.Serializer): username = serializers.CharField() password = serializers.CharField() def validate(self, data): user = authenticate(**data) if user and user.is_active: return user raise serializers.ValidationError("invalid details") settings.py: REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.BasicAuthentication', 'knox.auth.TokenAuthentication' ), 'DEFAULT_PERMISSIONS_CLASSES': ( 'rest_framework.permissions.AllowAny', ) } -
"detail": "CSRF Failed: CSRF token missing or incorrect." Django Rest Framework
My Error: { "detail": "CSRF Failed: CSRF token missing or incorrect." } My Model: class Booking(models.Model): booking_id = models.AutoField(primary_key=True) booking_owner = models.TextField(max_length=20) booking_city = models.TextField(max_length=20) booking_place = models.TextField(max_length=20) booking_arrival = models.DateField() booking_departure = models.DateField() booking_vehicle = models.TextField(max_length=20) booking_amount = models.TextField(max_length=20) booking_payment_date = models.DateField(default=now) booking_status = models.TextField(max_length=10, default=None, blank=True, null=True) booking_payment_status = models.TextField(max_length=10, default=None, blank=True, null=True) booking_entrance_time = models.TimeField(default=None, blank=True, null=True) booking_exit_time = models.DateTimeField(default=None, blank=True, null=True) def __str__(self): return "%s - %s" % (self.booking_id, self.booking_city) My Serializer: class AddBookingSerializer(serializers.ModelSerializer): class Meta: model = Booking fields = '__all__' My View: class BookingAddAPI(APIView): @staticmethod def post(request): data = {} try: serializer = WitPark.serializers.AddBookingSerializer(data=request.data) if serializer.is_valid(): serializer.save() data['status'] = status.HTTP_201_CREATED data['message'] = "Data saved successfully" else: data['status'] = status.HTTP_204_NO_CONTENT data['message'] = "Invalid data" except Exception as e: data['status'] = status.HTTP_404_NOT_FOUND data['message'] = "Failed to save the data" data['error'] = e return Response(data=data) I have also other POST methods. This post method is working fine in localhost but not working in live server (pythonanywhere.com) All other methods are also working fine on live server except this one -
Django Pagination in ListView does not have page_obj?
I am a little confused here... I have assigned paginate_by within my class but it simply does not paginate. I have read many articles about query_set and others but nothing seems to solve my issue. Here is my original view: class Clients(ListView): paginate_by = 5 model = Client template_name = 'clients.html' def get_clients_view(self, request): """ Primary View """ last_name = request.GET.get('last_name', '') email = request.GET.get('email', '') if request.method == 'GET': object_list = Client.objects.filter(last_name__contains=last_name).filter(email__contains=email) register_form = ClientRegisterForm(request.POST) remove_form = ClientRemoveForm(request.POST) search_form = ClientSearchForm(request.GET) update_form = ClientUpdateForm(request.POST) client_context= { 'object_list' : object_list, 'register_form' : register_form, 'remove_form' : remove_form, 'search_form' : search_form, 'update_form' : update_form } return render(request, template_name='clients.html', context=client_context) As well as my nav: <nav class="step-links"> {% if is_paginated %} {% if page_obj.has_previous %} <a href="?page=1">&laquo; first</a> <a href="?page={{ page_obj.previous_page_number }}">previous</a> {% endif %} {% if page_obj.number %} <p class="current"> Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}. </p> {% endif %} {% if page_obj.has_next %} <a href="?page={{ page_obj.next_page_number }}">next</a> <a href="?page={{ page_obj.paginator.num_pages }}">last &raquo;</a> {% endif %} {% else %} <p> Is not paginated.</p> {% endif %} </nav>