Changes between Version 4 and Version 5 of DjangoCheatSheet


Ignore:
Timestamp:
06/20/06 00:46:51 (9 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DjangoCheatSheet

    v4 v5  
    77django-admin.py startproject AcmeIntranet
    88cd AcmeIntranet
    9 edit settings.py
     9mkdir templates
     10mkdir media
    1011}}}
    1112
     13'''settings.py'''
    1214 * edit your database settings
    1315 * set path to media dir ( e.g. /home/joe/AcmeIntranet/media )
     
    2325
    2426
    25 == Creating an application... ==
     27== Creating an ''invoices'' application... ==
    2628
    2729{{{
     
    3234
    3335
    34 '''edit invoices/models.py'''
     36'''create your data model'''
    3537{{{
    3638from django.db import models
     
    4951python manage.py syncdb
    5052}}}
     53see: [http://www.djangoproject.com/documentation/model_api/ model api], [http://www.djangoproject.com/documentation/models/ model examples]
    5154
    5255
    5356
    54 '''urls'''
     57'''design your urls'''
    5558
    5659in the project root directory, edit urls.py:
     
    6265{{{
    6366from django.conf.urls.defaults import *
    64 from AcmeIntranet.invoices.models import Invoice
     67from jmgenie.dbdoorman.models import Ticket
    6568
    6669info_dict = {
    67   'queryset': Invoice.objects.all()
     70  'queryset': Ticket.objects.all()
    6871}
    6972
    7073urlpatterns = patterns('',
    7174    (r'^$', 'django.views.generic.list_detail.object_list', info_dict),
    72     (r'^new/$', 'django.views.generic.create_update.???', { 'model': Invoice } ),
     75    (r'^new/$', 'django.views.generic.create_update.create_object', { 'model': Ticket } ),
    7376    (r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict),
    7477)
    7578}}}
     79''see: [http://www.djangoproject.com/documentation/generic_views/ generic views]
     80
     81'''Create your templates'''
     82
     83First create ''Acme_base.html'' in templates
     84
     85Next create ''invoice_list.html'' in templates/invoices
     86{{{
     87{% extends "Acme_base.html" %}
     88
     89{% block title %} Listing Invoices {% endblock %}
     90
     91{% block content %}
     92  {% for invoice in object_list %}
     93    <p>{{ invoice.dollar_ammount }}</p>
     94  {% endfor %}
     95{% endblock %}
     96}}}
     97
     98
     99''see: [http://www.djangoproject.com/documentation/templates/ template authoring guide]
    76100
    77101
    78102
    79 
Back to Top