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, with a special focus on less code, no-redundancy and being more explicit than implicit.

Filter by
Sorted by
Tagged with
484votes
36answers
1.9mviews

'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: ...
user avatar
  • 7,903
145votes
5answers
174kviews

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)...
user avatar
  • 40.7k
765votes
14answers
375kviews

How can I combine two or more querysets in a Django view?

I am trying to build the search for a Django site I am building, and in that search, I am searching in three different models. And to get pagination on the search result list, I would like to use a ...
user avatar
  • 10.8k
511votes
15answers
281kviews

Extending the User model with custom fields 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). ...
user avatar
  • 16.8k
728votes
10answers
389kviews

How to upload a file in Django? [closed]

As a newbie to Django, I am having difficulty making an upload app in Django 1.3. I could not find any up-to-date example/snippets. May someone post a minimal but complete (Model, View, Template) ...
user avatar
  • 11.3k
407votes
10answers
582kviews

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 (...
user avatar
  • 5,442
564votes
24answers
204kviews

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/...
user avatar
  • 102k
205votes
23answers
188kviews

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 ...
user avatar
  • 4,350
278votes
8answers
188kviews

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 ...
user avatar
  • 34.7k
309votes
21answers
288kviews

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
user avatar
  • 6,127
565votes
6answers
322kviews

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): ...
user avatar
  • 57.2k
277votes
10answers
95kviews

Dynamically adding a form to a Django formset

I want to dynamically add new forms to a Django formset, so that when the user clicks an "add" button it runs JavaScript that adds a new form (which is part of the formset) to the page.
user avatar
  • 3,989
1184votes
24answers
388kviews

What is the difference between null=True and blank=True in Django?

When we add a database field in django we generally write: models.CharField(max_length=100, null=True, blank=True) The same is done with ForeignKey, DecimalField etc. What is the basic difference in ...
user avatar
  • 16.7k
431votes
12answers
417kviews

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 ...
user avatar
  • 33.3k
497votes
28answers
357kviews

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 ...
user avatar
  • 15.8k

15 30 50 per page
1
2 3 4 5
1573