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.
django
25,365
questions
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: ...
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 ...
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)...
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 ...
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).
...
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 (...
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?
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):
...
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/...
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 ...
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 ...
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 ...
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 ...
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
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 ...