Django

Code

Changeset 142

Show
Ignore:
Timestamp:
07/17/05 01:11:33 (3 years ago)
Author:
adrian
Message:

Finished tutorial02 and added a link to it from tutorial01

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/tutorial01.txt

    r104 r142  
    1 ======================================= 
    2 Tutorial: Writing your first Django app 
    3 ======================================= 
     1===================================== 
     2Writing your first Django app, part 1 
     3===================================== 
     4 
     5By Adrian Holovaty <holovaty@gmail.com> 
    46 
    57Let's learn by example. 
     
    369371For full details on the database API, see our `Database API reference`_. 
    370372 
     373When you're comfortable with the API, read `part 2 of this tutorial`_ to get 
     374Django's automatic admin working. 
     375 
    371376.. _Database API reference: http://www.djangoproject.com/documentation/db_api/ 
    372  
    373 Coming soon 
    374 =========== 
    375  
    376 The tutorial ends here for the time being. But check back within 48 hours for 
    377 the next installments: 
    378  
    379 * Using the dynamically-generated admin site 
    380 * Writing public-facing apps 
    381 * Using the cache framework 
    382 * Using the RSS framework 
     377.. _part 2 of this tutorial: http://www.djangoproject.com/documentation/tutorial2/ 
  • django/trunk/docs/tutorial02.txt

    r141 r142  
    435435think they should. 
    436436 
    437 More 
    438 ==== 
    439  
    440 There's much more to come. This document is not finished. 
     437Customize the admin look and feel 
     438================================= 
     439 
     440Clearly having "Django administration" and "mysite.com" at the top of each 
     441admin page is ridiculous. It's just placeholder text. 
     442 
     443That's easy to change, though, using Django's template system. 
     444 
     445Open your admin settings file and look at the ``TEMPLATE_DIRS`` setting. 
     446``TEMPLATE_DIRS`` is a tuple of filesystem directories to check when loading 
     447Django templates. It's a search path. 
     448 
     449The ``django-admin.py startproject`` command automatically prepopulated 
     450this setting with the location of Django's default admin templates, according 
     451to where you have Django installed. But let's add an extra line to 
     452``TEMPLATE_DIRS`` so that it checks a custom directory first, before checking 
     453the default admin template directory:: 
     454 
     455    TEMPLATE_DIRS = ( 
     456        "/home/mytemplates/admin", 
     457        "/usr/lib/python2.3/site-packages/django/conf/admin_templates", 
     458    ) 
     459 
     460Now copy the template ``base_site.html`` from within the default Django admin 
     461template directory, into ``/home/mytemplates/admin`` (or wherever you're 
     462putting your custom admin templates). Edit the file and replace the generic 
     463Django stuff with your own site's name as you see fit. 
     464 
     465Note that any of Django's default admin templates can be overridden. To 
     466override a template, just do the same thing you did with ``base_site.html`` -- 
     467copy it from the default directory into your custom directory, and make 
     468changes. 
     469 
     470Customize the admin index page 
     471============================== 
     472 
     473On a similar note, you might want to customize the look and feel of the Django 
     474admin index page. 
     475 
     476By default, it displays all available apps, according to your ``INSTALLED_APPS`` 
     477setting. But the order in which it displays things is random, and you may want 
     478to make significant changes to the layout. After all, the index is probably the 
     479most important page of the admin, and it should be easy to use. 
     480 
     481The template to customize is ``index.html``. (Do the same as with 
     482``base_site.html`` in the previous section -- copy it from the default directory 
     483to your custom template directory.) Edit the file, and you'll see it uses a 
     484template tag called ``{% get_admin_app_list as app_list %}``. That's the magic 
     485that retrieves every installed Django app. Instead of using that, you can 
     486hard-code links to object-specific admin pages in whatever way you think is 
     487best. 
     488 
     489Django offers another shortcut in this department. Run the command 
     490``django-admin.py adminindex polls`` to get a chunk of template code for 
     491inclusion in the admin index template. It's a useful starting point. 
     492 
     493Coming soon 
     494=========== 
     495 
     496The tutorial ends here for the time being. But check back within 48 hours for 
     497the next installments: 
     498 
     499* Writing public-facing apps 
     500* Using the cache framework 
     501* Using the RSS framework 
     502* Using the comments framework