Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [django]

Django is an open-source server-side web application framework written in Python. It is designed to reduce the effort required to create complex data-driven websites and web applications, focusing on less code, no redundancy and being more explicit than implicit.

584 votes
42 answers
3.0m views

'pip' is not recognized as an internal or external command

I'm running into a weird error when trying to install Django on my computer. This is the sequence that I typed into my command line: C:\Python34> python get-pip.py Requirement already up-to-date: ...
user3597950's user avatar
  • 9,841
516 votes
21 answers
231k views

Why does DEBUG=False setting make my django Static Files Access fail?

Am building an app using Django as my workhorse. All has been well so far - specified db settings, configured static directories, urls, views etc. But trouble started sneaking in the moment I wanted ...
JWL's user avatar
  • 14k
177 votes
6 answers
235k views

What is a NoReverseMatch error, and how do I fix it?

I have some code and when it executes, it throws a NoReverseMatch, saying: NoReverseMatch at /my_url/ Reverse for 'my_url_name' with arguments '()' and keyword arguments '{}' not found. n pattern(s)...
Sayse's user avatar
  • 43.1k
834 votes
16 answers
479k views

How to combine multiple QuerySets in Django?

I'm trying to build the search for a Django site I am building, and in that search, I am searching across three different models. And to get pagination on the search result list, I would like to use a ...
espenhogbakk's user avatar
  • 11.7k
550 votes
17 answers
338k views

What's the best way to extend the User model in Django?

What's the best way to extend the User model (bundled with Django's authentication app) with custom fields? I would also possibly like to use the email as the username (for authentication purposes). ...
Farinha's user avatar
  • 18k
503 votes
12 answers
803k views

CORS: Cannot use wildcard in Access-Control-Allow-Origin when credentials flag is true

I have a setup involving Frontend server (Node.js, domain: localhost:3000) <---> Backend (Django, Ajax, domain: localhost:8000) Browser <-- webapp <-- Node.js (Serve the app) Browser (...
ixaxaar's user avatar
  • 6,659
744 votes
10 answers
442k views

How to upload a file in Django? [closed]

What is the minimal example code needed for a "hello world" app using Django 1.3, that enables the user to upload a file?
qliq's user avatar
  • 11.8k
686 votes
6 answers
452k views

What is related_name used for?

What is the related_name argument useful for on ManyToManyField and ForeignKey fields? For example, given the following code, what is the effect of related_name='maps'? class Map(db.Model): ...
zjm1126's user avatar
  • 65.8k
586 votes
26 answers
223k views

Set up a scheduled job?

I've been working on a web app using Django, and I'm curious if there is a way to schedule a job to run periodically. Basically I just want to run through the database and make some calculations/...
TM.'s user avatar
  • 110k
315 votes
19 answers
371k views

How can I use the variables from "views.py" in JavasScript, "<script></script>" in a Django template?

When I render a page using the Django template renderer, I can pass in a dictionary variable containing various values to manipulate them in the page using {{ myVar }}. Is there a way to access the ...
AlMcLean's user avatar
  • 3,509
318 votes
11 answers
235k views

Django template how to look up a dictionary value with a variable

mydict = {"key1":"value1", "key2":"value2"} The regular way to lookup a dictionary value in a Django template is {{ mydict.key1 }}, {{ mydict.key2 }}. What if the key is a loop variable? ie: {% for ...
Stan's user avatar
  • 38k
221 votes
23 answers
220k views

Django CSRF check failing with an Ajax POST request

I could use some help complying with Django's CSRF protection mechanism via my AJAX post. I've followed the directions here: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/ I've copied the ...
firebush's user avatar
  • 5,690
521 votes
13 answers
577k views

How to query as GROUP BY in Django?

I query a model: Members.objects.all() And it returns: Eric, Salesman, X-Shop Freddie, Manager, X2-Shop Teddy, Salesman, X2-Shop Sean, Manager, X2-Shop What I want is to know the best Django way ...
simplyharsh's user avatar
  • 36.2k
344 votes
20 answers
347k views

Numeric for loop in Django templates

How do I write a numeric for loop in a Django template? I mean something like for i = 1 to n
Lev's user avatar
  • 6,617
534 votes
30 answers
433k views

In a Django form, how do I make a field readonly (or disabled) so that it cannot be edited?

In a Django form, how do I make a field read-only (or disabled)? When the form is being used to create a new entry, all fields should be enabled - but when the record is in update mode some fields ...
X10's user avatar
  • 17.7k

15 30 50 per page
1
2 3 4 5
1691