Click here to Skip to main content
15,891,657 members
Everything / Django

Django

Django

Great Reads

by Danny Chu
Learn how to detect if client has JavaScript enabled or disabled at your backend webserver
by Ahmed Bouchefra
In this tutorial, we’ll see by example how to create a CRUD application from scratch and step by step. We’ll see how to configure a MySQL database, enable the admin interface, and create the django views.
by Mikhail Smirnov
How to create a tool that helps to collect​ and analyze vital statistics information about users in one place​ using JavaScript.
by Programming Tutorials by Tests4Geeks
Django is all about making programmers more productive. As a web application framework, it provides tools and structure to help web developers get their work done fast.

Latest Articles

by Manoj Mohan 07
Use Django to visualize download stats of Python packages and gain insights into package popularity and usage trends
by Arctype SQL
When solving a problem that requires you to link a user's session data to their actual user object, Postgres comes in handy.
by Gen1us2k
Run GeoDjango on Elasticbeanstalk container using Python
by Ahmed Bouchefra
In this tutorial, we’ll see by example how to create a CRUD application from scratch and step by step. We’ll see how to configure a MySQL database, enable the admin interface, and create the django views.

All Articles

Sort by Title

Django 

3 Jul 2019 by Cloudster
Deploy a 360 image gallery with Django, Bootstrap, Python, A-Frame, and PostgreSQL
9 Jul 2022 by Kavya Bhargava
I got this error while running python manage.py makemigrations. I was using the attris in the right way as searched by me in google: Form fields: image = forms.ImageField(required=False, widget=forms.FileInput(attris={'class':...
9 Jul 2022 by Richard MacCutchan
See Widgets | Django documentation | Django[^], the property is named attrs not attris, and is a property of the widget class.
2 Dec 2020 by Member 15009998
i have an issue while i call get api http://localhost:8000/auth/users/me/(django djoser simplejwt) cors blocked issue is occure.cant get any data and api error is happening. my react frontend like this export const fetchUser = () => {...
2 Dec 2020 by Richard Deeming
Quote: const config = { headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}`, "Access-Control-Allow-Origin" : "", "Allow": "GET", "Content-type": "Application/json", } }; There is...
18 Apr 2022 by crevs ftb
**I have been trying to update and add + 1 in the database model (sessions) field whenever a button is being clicked. i am trying to be able to add +1 in a database field whenever a user clicks on a button and have that +1 record and time when...
17 Apr 2022 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
8 Feb 2023 by amr aly
Hi all, I’ve two issues The first one: as you can see in the second image (when cloning select input with select2 plugin, the cloned input appears with (the first disabled item appended next to the main input in every row)). [Original row...
10 Feb 2023 by amr aly
Thanks @Member 15627495 and I can't forget your advises But I took time to fix it as follow with one ajax call $(document).on('change', '.product', function(e){ var product_id = $(this).val(); let $el =...
23 Nov 2022 by Eva Smirnova
import uuid from django.db import models from django.core import validators from django.contrib.auth.models import User from django.db.models.base import Model from django.db.models.deletion import SET, SET_NULL from...
23 Nov 2022 by Richard MacCutchan
The message is telling you that the database could not find a Book record with a pk of 1. Check the contents of the database tables to see exactly what it does have.
4 Apr 2021 by Mahdi Yaghoubi
I am trying to save data that fill out with form to database but it doesn't work as well. when i click on Submit button nothing change, the webpage just refresh! These are my codes. Views.py class HotelAdCreate(AuthorsAccessMixin,CreateView): ...
30 Mar 2020 by OriginalGriff
To be honest, if you have to ask these questions, then you shouldn't be going near this project yet: you are dealing with real money, and that means two things: 1) You need to know exactly what you are doing, and do it correctly, or you will...
9 Jan 2018 by Programming Tutorials by Tests4Geeks
Django is all about making programmers more productive. As a web application framework, it provides tools and structure to help web developers get their work done fast.
17 Apr 2022 by OriginalGriff
See here: python - Django 404 error-page not found - Stack Overflow[^]
4 Jul 2022 by Member 15697002
I am trying to getting flag icon on every edit form of each datatable row have edit button. but unfortunately I can see flag icon only in 1st row of edit form of datatable grid. and in other rows I am not able to see flag icon. Can you help us...
21 Mar 2014 by christo4040
I am trying to create a like button for my site. The code below is what I have tried to do, it did not work. Can anyone help me? models.pyclass Like(models.Model): user = models.ForeignKey(User) post = models.ForeignKey(Posts) created =...
19 Nov 2015 by Member 12153818
I am trying to develop a log in web application that can be accessed by multiple clients. So far I have made a simple log in page, using a template in python tools for visual studio, in visual studio 2013. The log in function works, getting data from a dqlite3 database. I have created a...
4 Apr 2022 by Member 13065765
Hi, I am basically pretty new in django and learning. I have started learning making APIs and authentications and stuffs like that. But I need some guidance. So, basically I am supposed to use some third party APIs for logging in which will...
4 Apr 2022 by Richard MacCutchan
This question is impossible to answer. You need to consult the documentation of the API(s) that you are using
23 Aug 2018 by Ruban Bharath
Hi these are my tables music_name = char(username),userId(int) meaning = char(meaning),userid(int) and i want to store the result on third table=music_result(username,meaning) i have used the join to merge this when i tried to do this i got an error like sqlite3.IntegrityError: datatype...
23 Aug 2018 by Herman<T>.Instance
ahhh now it is clear: class result(models.Model): userid = models.IntegerField(primary_key=True) a PrimaryKey field cannot be NULL. Can you set it up as Identity field. A number for ID is than generated and is not needed in the INSERT query.
5 Dec 2021 by Richard MacCutchan
You already posted this question at Dec 5, 2021 I need this date format by using django and show that into HTML template[^], and received an answer. Please do not repost.
6 Apr 2021 by Muhammad Din Khairul Izman
hello I am trying to create a website that saves the name and time when a person clocks in to a database, but the time that was stored is off by 8 hours. Here is the code: from django.db import models from datetime import datetime, date ...
24 Mar 2021 by Arctype SQL
When solving a problem that requires you to link a user's session data to their actual user object, Postgres comes in handy.
18 Apr 2020 by Major Morph
Hello Everyone! I recently started with Django and I found a project on GitHub and I downloaded it and started working on it but it was created with Django version 1.4.2 is there any way to upgrade the whole project in the new version of Django...
18 Apr 2020 by Maciej Los
Django 1.4 release last term support ended with october 2015. See: Download Django | Django[^] You have to update your code accrodingly to the current version of Django installed on your OS. Quote: I have tried to modify the files manually...
4 Jan 2019 by Member 14108446
Hi everyone, I am currently learning Djnago and situation is the following. I have a legacy database, I connected it to Django. In this database I have names of schools. I have written a code in python that uses those names and returns lat and lng from Google API. Here is the code: def...
3 Nov 2019 by Ves93
I know how to reverse a loop inside the template: {% ... | reverse %} But I cannot do the same thing when the for loop is inside views.py. I cannot find a syntax for this. What I have tried: import requests from django.shortcuts import render, get_object_or_404 from django.http import...
3 Nov 2019 by RickZeeland
Maybe you can use reverse in your City class to return the result, something like this: return reverse(bla, blabla) Also see: Django Tutorial Part 6: Generic list and detail views - Learn web development | MDN[^] class Author(models.Model): ... return reverse('author-detail', args=[str(self.id)])
3 Nov 2019 by RickZeeland
I found some documentation on page 140 here: Sams Teach Yourself Django in 24 Hours - Brad Dayley - Google Boeken[^] {% for title in books reversed %} Although the chapter is about Views, it might still be a template thing, this is not very clear ...
3 Nov 2019 by Ves93
So this code is working perfectly. However, I need the user to be able to change the value of the variable "city." At the moment it's equal to 'London', and if I type a valid city name, the appropriate result appears on screen. I am using an API, so they have all the cities on their database. ...
3 Nov 2019 by RickZeeland
Maybe this tutorial will help: https://www.tutorialspoint.com/django/django_form_processing.htm[^]
15 Dec 2019 by Ahmed Bouchefra
How to send Ajax requests in Django 2 and Python 3.7 to add CRUD operations in your application and manipulate your Django models and database without having to refresh your web pages each time
15 Dec 2019 by Ahmed Bouchefra
A Django 2 CRUD example application using generic class based views using the latest Python 3.7 version
15 Jan 2020 by Ahmed Bouchefra
In this tutorial, we’ll see by example how to create a CRUD application from scratch and step by step. We’ll see how to configure a MySQL database, enable the admin interface, and create the django views.
29 Oct 2013 by Software Developer's Journal
8 Apr 2021 by Padala Kavya
So I am building this debate app where a question is posted and the user chooses the option to agree,disagree or have a neutral opinion. When the user chooses the option I want them to type the reason in textbox after choosing the option and then...
6 Jan 2014 by Member 10508281
I am using Django 1.6 and i create one login API and create session on login. problem is that when i am already logged in and try to login again i got new session variable. i want same variable.Login APIdef login(request): """Documentation for login function. the login function is used...
28 Nov 2022 by Eva Smirnova
Hello, what extension do I need to install for code highlighting templates in django? What I have tried: Tried different options but nothing worked.
25 Nov 2022 by Richard MacCutchan
I assume you mean highlighting while you are editing, then any of the Python editors will do it. I use VSCode, but you can also try IDLE, which is distributed with Python. Google will find you other possibilities which you can try for yourself.
28 Nov 2022 by Eva Smirnova
That no one knows the extension for the template?
28 Nov 2022 by Richard Deeming
Python in Visual Studio Code[^] Python - Visual Studio Marketplace[^]
18 Sep 2017 by Andriken
i have no idea what happen to django , i am using django 1.8.6 and with python 3.5.2 i am working on form's and the form's validation like field validation work's well but i noticed the validation error for empty field was'nt rasing an error, by default django set required field to True , and...
10 Jun 2021 by Thabo Pali
How do I query a remote database particularly an Oracle (or any database) database, do I have to create a model for the database? Also why would I need to create a model for the tables in that database if the tables already exist? What I have...
14 Jul 2022 by Kavya Bhargava
My form is receiving data when I put values in it but it is not displaying it in HTML. models.py: user = models.OneToOneField(User, on_delete = models.CASCADE) image = models.ImageField(default = 'default.jpg', upload_to =...
3 Feb 2016 by Member 12306946
I'm trying to make a code-name(*i.e: Test Post will be TP-1, TP-2 ...*) thing on Django. There is **news** model, and **post** model i got. When user create news title hence post's codename will be according it's news's title. For example the `news.title='Test News'` then assume that I...
23 Oct 2021 by Lucas R.G
I have an array in Django views.py and I want to send it to HTML and display a pie chart, but failed, I've tried many other methods and read many tutorials, in most of the case, they have a field in models that store some number, and...
23 Aug 2014 by JustCurious'1
Hello There. I am working on a small website and I need to send thread-post data through JSON.This is the JSON object django serves:[{"text":"Some sample text","id":"21","title":"Test Thread"}]I saved this as a .js file and the following Javascript code works fine:
7 May 2016 by Member 12508489
I am trying to learn django and had create a simple website but the problem is when I try to insert bootstrap the layout is display incorrectly and then I found out the problem is with this empty:which automatic inserted( I had tried to insert empty html...
27 Jan 2022 by materialAres
I have to do this project of classified ads for Coursera. Essentially every user can post, update and delete advertisements. The problem is that even if the objects are correctly stored (I checked tables and objects via admin and manually with...
13 Jul 2022 by Berk Ö.
I am working on a Social Media Website, the base code is from an Open Source Project on GitHub. On the base project you can only post text. I was looking around the Internet and found a instruction to implement img upload. But it doesn't work,...
13 Jul 2022 by Richard MacCutchan
You will never get this right just by copying someone else's code and watching YouTube videos. You need to get a good understanding of Django and how it operates. There is a good example of how to handle forms and the associated POST methods at...
9 Jul 2022 by ckcRichard
currently the way I have the code written is that I have a model named Finances. I have an aggregate set up so it sums up all of the rows. I am trying to display the outcome of the rows, but when I do it displays a row for every database entry. ...
9 Jul 2022 by Member 15678123
You are looping all on all the {% for finances in viewpayout %} objects hence it's going to render multiple of course. Try below: def finances(request): totalpayout = Finances.objects.all().aggregate(Sum('payout'))['payout__sum'] or...
4 Jul 2022 by Member 15696853
after deleting records it is not redirecting to the page I wanted instead it is showing me an error. But after going back and refresh the page the record is deleted successfully. Here is the code : - html page :
23 Oct 2013 by daizhan
In Django1.5 documentation , there is a section about related_name. the last paragraph is "If you’d prefer Django not to create a backwards relation, set related_name to '+' or end it with '+'. For example, this will ensure that the User model won’t have a backwards relation to this model:user =...
9 Jan 2018 by Programming Tutorials by Tests4Geeks
Django REST Framework tutorial
18 Jul 2021 by ankur paranjpe
Using Django 3.2 with Restframework. Im trying for search filter and create a API with restframework which would output the searched term with its whole object. I had a little success on that with official doc. But from that I can only search in...
11 May 2015 by Alexander24
I am working in a small project using Angularjs and Django. I have two different models with its corresponding end points.class Skills(models.Model): skills = models.CharField(max_length=100) def __str__(self): return self.skills class...
29 May 2017 by Farah M. Chaaban
Hello i don't know what is the problem with my template. My template is decomposed into 3 types of radio buttons : Long, short, long and short When i click on each radio button a form appears. Till now everything is okay. But i want to put in the form of radio button "long and short", two...
29 May 2017 by Farah M. Chaaban
problem code project - Album on Imgur[^]
9 May 2022 by Jay Arora 2021
when I run python manage.py tests I get this error as django.db.utils.IntegrityError: UNIQUE constraint failed: books_book.id it causes most of the other tests to fail What I have tried: Here are the full tests.py file: class...
9 May 2022 by karima hadj-rabah
Hi there, how did you fix the problem ?? I have the same issue and I didn't find a way to fix it and Thank you.
9 Jul 2022 by Mathis 2022
My problem is that over time the memory usage (especially the virtual memory) increases until the system freezes. There is hardly not traffic on the server and it seems to happen independendly from making any HTTP-Request. Last time the virtual...
31 Oct 2017 by Member 13496220
How do i connect to HIVE in Django web Framework and what are the possibilities if any possibility pls share code or thoughts . i am searching for past 2 weeks What I have tried: i dont have any idea about how to connect
22 Nov 2017 by vijith.squadz
You can use "pyodbc" module to connect to Hive.
1 Aug 2022 by Kavya Bhargava
raise IntegrityError( django.db.utils.IntegrityError: The row in table 'jobs_jobs' with primary key '1' has an invalid foreign key: jobs_jobs.company_id contains a value 'Google' that does not have a corresponding value in jobs_company.id. This...
1 Aug 2022 by OriginalGriff
The error is saying that the database can't store that information because there is a problem with a foreign key field. A Foreign Key is a field that establishes a relationship between two tables: the value will be the same in both tables. For...
23 Jul 2023 by Berk Ö.
Hello I am working on a Social Media Page where Users can upload Images. The uploaded Files are in my BLOG Folder, where also my Feed.html is placed where the Content is displayed. But I want to show the uploaded Files to my Profile.hmtl as...
29 Oct 2019 by justin 7
I am not really good when it comes in trigger trigger thing. I just want that if the admin update the StudentsEnrollmentRecord, it will trigger the SubjectSectionTeacher and it will save in StudentsEnrolledSubject. can you guys help me solve this problem? especially in PostgreSQL Trigger What I...
2 Nov 2021 by harika reddy
def a1(request): if request.method == "POST": add = request.POST['addition'] while True: add = add + 1 print(add) time.sleep(2) return render(request, blog/finished.html) def...
9 Apr 2022 by crevs ftb
Hello My Brothers & Sisters Thank YOU, I managed to sort out the error by adding an index to int, but i am faced with a new error: invalid literal for int() with base 10: 'sessions' MYNEWCODE def subs(request, pk): sw =...
8 Apr 2022 by crevs ftb
Hello my fellow brothers and sisters, i have been trying to take an integer value in the database and add/remove +/- 1, whenever i click on a button, its been killing me heating my head back and forth would appreciate the help. Thank YOU. ...
8 Apr 2022 by markkuk
The map() function[^] returns an iterator and you must convert it to a list before you can serialize it. return JsonResponse(list(sw_list), safe=False)
27 Jan 2023 by Vaishh
I am trying to delete a file on click of delete button from the html table and move that file from pending to delete folder What I have tried: views.py def pending(request): id=request.GET.get('id') ...
11 Aug 2020 by Richard MacCutchan
You already posted this question at drawing-a-polygon-on-image-inside-canvas-after-zoom-in-out-and-panning - JavaScript Discussion Boards[^]. Please do not crosspost.
31 Mar 2020 by Member 14088544
Hi Developers, Hope you are all well from Corona I am making a final year project of Computer Science Degree in Python,Django. One module of that project is exam scheduling. I tried my best to make a exam scheduling module but could not do...
31 Mar 2020 by Nelek
Sorry... but it is your final year project and you give the impression of not having a clue on what was taught during the year. You are not asking anything. You are just giving your assignment and trying to get us do it for you. That's not going...
31 Mar 2020 by OriginalGriff
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, it's part of your grades and it wouldn't be at all fair for us to do it all for you. So we need you to...
31 Mar 2020 by Patrice T
Quote: Hope you are all well from Corona Personally, I prefer Chimay and Orval. :) Quote: I tried my best to make a exam scheduling module but could not do that. So please help me. The problem is that your description is so vague that I can...
3 Nov 2019 by Teffany Mae Reyes
I am trying to run my tensorflow script so that the result image will be exported and will be use to my site. At first, I'm using flask but I decided to shift to django because the script is too slow read and sometimes it won't run. That's why, I use django. But then, the script still wont run....
3 Nov 2019 by RickZeeland
Maybe this tutorial will help: Tensorflow Project #6: Django and Tensorflow Integration - YouTube[^]
12 May 2022 by Member 15629421
It shows error in pd=User.objects.get(id=user_id) What I have tried: views.py def editConsultant(request): if request.method=='POST': name=request.POST.get('name') phone=request.POST.get('phone') ...
24 May 2022 by Ernest Jan Sandoval
i get this error when i do runserver. What I have tried: views.py from django.shortcuts import render, redirect from .forms import NewUserForm from django.contrib.auth import login from django.contrib import messages def...
12 Feb 2019 by MukeshKumarTech
This article will demonstrate how to create the first Django Python application in Visual Studio.
25 Mar 2021 by Member 15118973
I am trying to make an IP Logger plus URL shortener. It says problem with line 82 in views.py - store_links.save() Getting an error: NOT NULL constraint failed: MyServer_links.redirect_url What I have tried: **views.py** from django.shortcuts...
20 Aug 2019 by Cloudster
Use Django logins to accept user "likes" and content submission
11 Feb 2019 by Member 14068174
Guys I am tried to relate my url in anchor tag of my html file but I am getting a no reverse match error ,The file i am trying to relate is having the right location also it, been initialised in views and urls too . Here,s the views.py code for this relative view from django.shortcuts import...
21 Jul 2021 by Socks92
I am working with Django, HTML and CSS. When using www.supportline.org.uk/problems/suicide/ in my HTML file to open a link on my web page I have no problems. However when inserting this link into a JSON text...
3 Oct 2016 by Bhuvanesh A
in my project , i want block a IP for accessing my site in django (create unwanted traffic or unwanted access the server that purpose)What I have tried:i don't know from where to start and where to finish, now i'm only have concept like above mentiond
3 Oct 2016 by F-ES Sitecore
django block ip - Google Search[^]
3 Oct 2016 by Karthik_Mahalingam
ask here Django view/track Tickets[^]Code.Django[^]
13 Dec 2020 by Gerry Schmitz
algorithm - Calculate distance between two latitude-longitude points? (Haversine formula) - Stack Overflow[^]
5 Sep 2014 by Member 11062637
I have made a custom group.How can i display all user groups present, as radio buttons (in template) so that user can select only one group while creating a user account & on save button, currently selected user group should be set as group of new user account?
11 Jul 2023 by AlexandruCrisan
I pretty much want to make a website that allows users to paste a link to any webpage and be able to see a preview of that page together with the html code behind it (just like you would use 'Inspect' in google chrome). The tricky part is making...
12 Jul 2023 by OriginalGriff
Basically, you'll have to write (or clone from Chromium) a new browser that lets you interact with the elements. You can embed a web browser in applications in some languages (.NET allows it pretty easily) but without access to the internals of...
1 Sep 2021 by Aylin Naebzadeh
Hello. I am creating some simple queries using the Django framework. I have one app which it has 8 models in models.py. Here are my classes: from django.db import models # Create your models here. class Category(models.Model): category_id...