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.


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.


Useful books




Popular Third Party Apps

Websites Using Django

See also:

309060 questions
28 answers

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

When we add a model 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 between: null=True only blank=True only null=True and…
  • 18,601
  • 10
  • 42
  • 55
29 answers

Has Django served an excess of 100k daily visits?

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
  • 33,434
  • 32
  • 105
  • 133
10 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?
  • 14,796
  • 9
  • 52
  • 76
17 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 =…
  • 45,039
  • 49
  • 151
  • 227
16 answers

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 generic object_list view to display the results.…
  • 11,508
  • 9
  • 39
  • 38
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…
  • 36,404
  • 64
  • 191
  • 318
14 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 below in this…
  • 19,422
  • 10
  • 54
  • 67
14 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
  • 9,923
  • 4
  • 33
  • 50
10 answers

How to upload a file in Django?

What is the minimal example code needed for a "hello world" app using Django 1.3, that enables the user to upload a file?
  • 11,695
  • 15
  • 54
  • 66
10 answers

Where does pip install its packages?

I activated a virtualenv which has pip installed. I did pip3 install Django==1.8 and Django successfully downloaded. Now, I want to open up the Django folder. Where is the folder located? Normally it would be in "downloads", but I'm not sure where…
  • 20,997
  • 28
  • 111
  • 214
11 answers

What does on_delete do on Django models?

I'm quite familiar with Django, but I recently noticed there exists an on_delete=models.CASCADE option with the models. I have searched for the documentation for the same, but I couldn't find anything more than: Changed in Django 1.9: on_delete can…
All Іѕ Vаиітy
  • 24,861
  • 16
  • 87
  • 111
32 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…
  • 7,657
  • 3
  • 20
  • 18
6 answers

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): members = models.ManyToManyField(User,…
  • 63,397
  • 81
  • 173
  • 221
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…
  • 33,075
  • 15
  • 67
  • 82
11 answers

How can I upgrade specific packages using pip and a requirements file?

I'm using pip with a requirements file, in a virtualenv, for my Django projects. I'm trying to upgrade some packages, notably Django itself, and I'm getting an error about source code conflicts: Source in /build/Django has version…
  • 6,447
  • 2
  • 17
  • 8
2 3
99 100