Django Djumpstart: Build a To-do List in 30 Minutes

Notice: This is a discussion thread for comments about the SitePoint article, Django Djumpstart: Build a To-do List in 30 Minutes.

Hi James, very nice tutorial!
what about using

todo_dict[‘percent_complete’] = todo_dict[‘items_complete’] * 100 / todo_dict[‘item_count’]

instead of

todo_dict[‘percent_complete’] = int(float(todo_dict[‘items_complete’]) / todo_dict[‘item_count’] * 100)

(whoops, something ate my first comment. Oh well)

It is a little easier and less convoluted to do it that way, but Python’s distinction between integer division and floating-point division is a pretty big “gotcha” for people new to the language, and I wanted to bring it out explicitly.

Sorry James

After trying for two hours to get django to work on a windows platform, i gave up. Just read the comments on the django-install page to know why you just shouldn’t try. For those who do want to try

  • don’t use python 2.5 (it doesn’t register, which is why the mysqldb part doesnt want to install) though the python guys say you should use 2.5.
  • read all of the user comment on the installpage of django, about 50 tips on getting it to work on windows, Quest of the day: find the one that works for you!

frustrated Michael

2nd night on it and I get so close… yet I’m so far. Could someone help with the following error that I get with 2 different install and special attention to the MySQLdb:

C:\\sokkit\\django\\build\\scripts\\gtd> syncdb
Traceback (most recent call last):
  File "C:\\sokkit\\django\\build\\scripts\\gtd\\", line 11, in ?
  File "c:\\sokkit\\python24\\lib\\site-packages\\Django-0.95-py2.4.egg\\django\\core\\m", line 1319, in execute_manager
    execute_from_command_line(action_mapping, argv)
  File "c:\\sokkit\\python24\\lib\\site-packages\\Django-0.95-py2.4.egg\\django\\core\\m", line 1243, in execute_from_command_line
  File "c:\\sokkit\\python24\\lib\\site-packages\\Django-0.95-py2.4.egg\\django\\core\\m", line 426, in syncdb
    from django.db import connection, transaction, models, get_creation_module
  File "c:\\sokkit\\python24\\lib\\site-packages\\Django-0.95-py2.4.egg\\django\\db\\__i", line 11, in ?
    backend = __import__('django.db.backends.%s.base' % settings.DATABASE_ENGINE
, '', '', [''])
  File "c:\\sokkit\\python24\\lib\\site-packages\\Django-0.95-py2.4.egg\\django\\db\\bac
kends\\mysql\\", line 12, in ?
    raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No mo
dule named MySQLdb

> {% for list_dict in todo_listing %}
> <h2>{{ list_dict.list_object.title }}</h2>
> …
> {% endfor %}

This pseudo-markup is “oogey” (sorry if that is too technical a term), like PHP is oogey.

It just feels hackneyed. Why not add a namespace to the <html> tag and use <django:for …> </django:for> or something a little more standard-ish. Meld your language add-on into the language you are extending instead of throwing everything away and coming in with orthogonal syntax?

I like XML+XSLT, data and language living in harmony. And (risking labeling here) lisp code lives in harmony with its data too. Why cant other emerging systems use these “best practices”?

Getting a jumpstart configuration to work under Windows can be a frustrating experience. The following steps worked for me:

  • Get Python 2.4 from Installation should not ne a problem, an MSI installer is provided. As soon as Python is installed, add the Python directory to the PATH environment variableas described in the article.
  • Use SQLite3 as lightweight DB engine. This means: Go to and get yourself the Pysqlite 2.x installer.
  • Download the Django distribution files (note that this package comes as tar.gz). After extraction, run “python install” as described in the article and set the PATH variable.

That should give you a working Windows environment.
Why SQlite/Pysqlite? It is sufficient for playing around, you always can tackle the juggernauts later. Just stay away from Python 2.5 for the time being, I did not yet find a working Pysqlite.

Hmm. Installing on windows was easy, I don’t know what the fuss is about. Use Python 2.4 though.

Don’t bother with MySQL. Just use Sqlite; simple, easy, works for what you want, i.e. to get going.

Templating languages are always a tradeoff; if you do an “HTML+namespace” or XML-style templating language, that has some benefits in terms of familiarity and compatibility with some types of parsing tools, but you also lose a lot of flexibility in terms of output formats – trying to output something that’s not an SGML or XML derivative from one of those templating languages can be a serious pain.

Django chose to go for flexibility, which is why the template language isn’t tied to an SGML/XML format; this means you can easily use the template system for lots of types of output without having to jump through lots of hoops.

So by your logic ORM is hackneyed and stupid because the code we write for data access doesn’t look like SQL?

Opps…a ROR book popup appears when you read the second page of the article.

Thanks for the guide. I accomplished something at work today!

well, those who don’t like the way Django templates look like can always use [URL=“”]kid (I assume it’s the same bunch that doesn’t like Smarty ;)).

still useful but check t his before using (you have to change maxlength to max_length etc) == the link is not allowed but look for ‘porting your apps…to 1.0’ in django docs

Some updated for Django 1.0.2

  1. use max_length instead of maxlength
  2. remove ‘class Admin pass’
    and replace it with a new in todo
    directory that has

from django.contrib import admin
from models import List
from models import Item

the new version is a killerapp!

Keep django growing :cool:

I know this topic is old but I am having issues creating this todo list.

So far I am getting this error when trying to run the program: -

Traceback (most recent call last):
  File "C:\\Django-1.2.5\\django\\bin\\gtd\	odo\\", line 1, in <module>
    from django.db import model
  File "C:\\Python27\\lib\\site-packages\\django\\db\\", line 14, in <module>
    if not settings.DATABASES:
  File "C:\\Python27\\lib\\site-packages\\django\\utils\\", line 276, in __getattr__
  File "C:\\Python27\\lib\\site-packages\\django\\conf\\", line 38, in _setup
    raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

Does anyone know how to fix this?? I would be very appreciative if anyone could help me out on this!