Changes between Version 3 and Version 4 of DjangoCheatSheet


Ignore:
Timestamp:
06/20/2006 12:09:44 AM (9 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DjangoCheatSheet

    v3 v4  
    22The django tutorials are quite good.  The goal of this cheat sheet is to create a quick start guide so that after reading the tuts over once or twice you have a more handy reference.  Things in this guide are done the 'right' way with generic views and templates right off the bat.  Please please add to this page.
    33
    4 == 1. Create a Django Project ==
     4== Starting a project... ==
    55
    66{{{
     
    1717  * ''your applications will likely have their own template dirs.  Remember to add those as you create them''
    1818
    19 == 2. Create ''invoices'' application. ==
    2019
    21 '''Edit urls.py''' to point to the app you will create
     20{{{
     21python manage.py syncdb
     22}}}
     23
     24
     25== Creating an application... ==
     26
     27{{{
     28python manage.py startapp invoices
     29
     30add 'AcmeIntranet.invoices', to INSTALLED_APPS list in settings.py
     31}}}
     32
     33
     34'''edit invoices/models.py'''
     35{{{
     36from django.db import models
     37from django.contrib.auth.models import User
     38
     39class Ticket (models.Model):
     40  user = models.ForeignKey (User)
     41  case_number = models.IntegerField()
     42  dollar_amount = models.FloatField('Cost (in dollars)', max_digits=10, decimal_places=2)
     43}}}
     44
     45validate your model and and commit to database:
     46{{{
     47python manage.py validate
     48python manage.py sql invoices
     49python manage.py syncdb
     50}}}
     51
     52
     53
     54'''urls'''
     55
     56in the project root directory, edit urls.py:
    2257{{{
    2358(r'^invoices/', include('AcmeIntranet.invoices.urls'))
    2459}}}
    2560
    26 Create the invoices app
    27 {{{
    28 python manage.py startapp invoices
    29 cd invoices
    30 }}}
    31 
    32 '''edit models.py'''
    33 {{{
    34 class Invoice(models.Model):
    35   dollar_ammount = models.FloatField('Cost (in dollars)', max_digits=10, decimal_places=2)
    36 }}}
    37 
    38 
    39 Create and '''edit urls.py'''
     61in the invoices app directory create urls.py:
    4062{{{
    4163from django.conf.urls.defaults import *
Back to Top