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.

PyPI

Django: The Web framework for perfectionists with deadlines

Django is a high-level web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers and maintained by the non-profit Django Software Foundation (DSF). it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.

Django follows the (model-view-controller) architectural pattern. This consists of:

  • an object-relational mapper that mediates between data models
    (Python classes) and a relational database ("Model")

  • a system for processing requests with a web templating system ("View")

  • a regular-expression-based URL dispatcher ("Controller")

The team prefers to think of Django as an "MTV" framework, where 'M' is the model, 'T' is the template and 'V' is view.

In , 'views' describe which data are presented while 'templates' describe how that data is presented.

Resources

Useful books

Tutorials

Newsletters

Podcasts

Popular Third Party Apps

Websites Using Django

See also:

267070 questions
1176
votes
29 answers

Does Django scale?

I'm building a web application with Django. The reasons I chose Django were: I wanted to work with free/open-source tools. I like Python and feel it's a long-term language, whereas regarding Ruby I wasn't sure, and PHP seemed like a huge hassle to…
Roee Adler
  • 31,157
  • 31
  • 99
  • 132
1080
votes
21 answers

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 having null=True only blank=True…
user993563
  • 15,357
  • 10
  • 40
  • 55
813
votes
8 answers

Is there a list of Pytz Timezones?

I would like to know what are all the possible values for the timezone argument in the Python library pytz. How to do it?
ipegasus
  • 12,519
  • 7
  • 45
  • 66
760
votes
15 answers

How do I do a not equal in Django queryset filtering?

In Django model QuerySets, I see that there is a __gt and __lt for comparative values, but is there a __ne or != (not equals)? I want to filter out using a not equals. For example, for Model: bool a; int x; I want to do results =…
MikeN
  • 39,649
  • 47
  • 142
  • 222
714
votes
14 answers

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 generic object_list view to display the results.…
espenhogbakk
  • 10,148
  • 8
  • 36
  • 36
708
votes
10 answers

How can I temporarily disable a foreign key constraint in MySQL?

Is it possible to temporarily disable constraints in MySQL? I have two Django models, each with a foreign key to the other one. Deleting instances of a model returns an error because of the foreign key constraint: cursor.execute("DELETE FROM…
jul
  • 33,288
  • 64
  • 178
  • 299
707
votes
10 answers

How to upload a file in Django?

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) example code to do so?
qliq
  • 10,991
  • 13
  • 51
  • 62
655
votes
11 answers

What is a "slug" in Django?

When I read Django code I often see in models what is called a "slug". I am not quite sure what this is, but I do know it has something to do with URLs. How and when is this slug-thing supposed to be used? (I have read its definition in this…
Jonas
  • 18,022
  • 9
  • 52
  • 67
607
votes
26 answers

How to check Django version

I have to use Python and Django for our application. So I have two versions of Python, 2.6 and 2.7. Now I have installed Django. I could run the sample application for testing Django succesfuly. But how do I make sure whether Django uses the 2.6 or…
maheshgupta024
  • 6,625
  • 3
  • 15
  • 17
607
votes
27 answers

How to debug in Django, the good way?

So, I started learning to code in Python and later Django. The first times it was hard looking at tracebacks and actually figure out what I did wrong and where the syntax error was. Some time has passed now and some way along the way, I guess I got…
googletorp
  • 32,389
  • 15
  • 62
  • 81
559
votes
11 answers

How to revert the last migration?

I've made a migration that added a new table and want to revert it and delete the migration, without creating a new migration. How do I do it? Is there a command to revert last migration and then I can simply delete the migration file?
Ronen Ness
  • 7,790
  • 4
  • 28
  • 43
544
votes
24 answers

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/updates on an automatic, regular basis, but I can't…
TM.
  • 94,986
  • 30
  • 119
  • 125
533
votes
10 answers

Separation of business logic and data access in django

I am writing a project in Django and I see that 80% of the code is in the file models.py. This code is confusing and, after a certain time, I cease to understand what is really happening. Here is what bothers me: I find it ugly that my model level…
521
votes
14 answers

Capturing URL parameters in request.GET

I am currently defining regular expressions in order to capture parameters in a URL, as described in the tutorial. How do I access parameters from the URL as part the HttpRequest object? My HttpRequest.GET currently returns an empty QueryDict…
sutee
  • 11,322
  • 12
  • 46
  • 60
518
votes
21 answers

How to reset Django admin password?

I am using Django (version 1.3) and have forgotten both admin username and password. How to reset both? And is it possible to make a normal user into admin, and then remove admin status?
IamH1kc
  • 5,442
  • 4
  • 15
  • 15
1
2 3
99 100