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:

309060 questions
632
votes
24 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
  • 6,602
  • 4
  • 19
  • 17
621
votes
18 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
  • 12,568
  • 13
  • 49
  • 61
609
votes
9 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…
608
votes
9 answers

How to filter empty or NULL names in a QuerySet?

I have first_name, last_name & alias (optional) which I need to search for. So, I need a query to give me all the names that have an alias set. Only if I could do: Name.objects.filter(alias!="") So, what is the equivalent to the above?
Val Neekman
  • 17,692
  • 14
  • 63
  • 66
585
votes
26 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.
  • 108,298
  • 33
  • 122
  • 127
574
votes
5 answers

How to define two fields "unique" as couple

Is there a way to define a couple of fields as unique in Django? I have a table of volumes (of journals) and I don't want more then one volume number for the same journal. class Volume(models.Model): id = models.AutoField(primary_key=True) …
Giovanni Di Milia
  • 13,480
  • 13
  • 55
  • 67
568
votes
38 answers

No module named pkg_resources

I'm deploying a Django app to a dev server and am hitting this error when I run pip install -r requirements.txt: Traceback (most recent call last): File "/var/www/mydir/virtualenvs/dev/bin/pip", line 5, in from pkg_resources import…
igniteflow
  • 8,404
  • 10
  • 38
  • 46
568
votes
17 answers

Creating a JSON response using Django and Python

I'm trying to convert a server side Ajax response script into a Django HttpResponse, but apparently it's not working. This is the server-side script: /* RECEIVE VALUE…
Switch
  • 14,783
  • 21
  • 69
  • 110
555
votes
12 answers

OneToOneField() vs ForeignKey() in Django

What's the difference between Django OneToOneField and ForeignKey?
redice
  • 8,437
  • 9
  • 32
  • 41
555
votes
42 answers

'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: pip in c:\python34\lib\site-packages Cleaning…
user3597950
  • 9,201
  • 6
  • 26
  • 35
541
votes
17 answers

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). I've already seen a few ways to do it, but can't…
Farinha
  • 17,636
  • 21
  • 64
  • 80
523
votes
30 answers

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 need to be read-only. For example, when creating a…
X10
  • 17,155
  • 7
  • 30
  • 28
522
votes
33 answers

No module named MySQLdb

I am using Python version 2.5.4 and install MySQL version 5.0 and Django. Django is working fine with Python, but not MySQL. I am using it in Windows Vista.
jbcedge
  • 18,965
  • 28
  • 68
  • 89
517
votes
6 answers

What's the difference between select_related and prefetch_related in Django ORM?

In Django doc: select_related() "follows" foreign-key relationships, selecting additional related-object data when it executes its query. prefetch_related() does a separate lookup for each relationship, and does the "joining" in Python. What does…
513
votes
12 answers

RuntimeWarning: DateTimeField received a naive datetime

I m trying to send a simple mail using IPython. I have not set up any models still getting this error. What can be done? Error : /home/sourabh/Django/learn/local/lib/python2.7/site-packages/django/db/models/fields/init.py:827: RuntimeWarning:…
shifu
  • 6,586
  • 5
  • 21
  • 21