~ubuntu-branches/ubuntu/quantal/python-django/quantal

« back to all changes in this revision

Viewing changes to docs/intro/tutorial01.txt

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2010-10-12 11:34:35 UTC
  • mfrom: (1.1.12 upstream) (29.1.1 maverick-security)
  • Revision ID: james.westby@ubuntu.com-20101012113435-yy57c8tx6g9anf3e
Tags: 1.2.3-1ubuntu0.1
* SECURITY UPDATE: XSS in CSRF protections. New upstream release
  - CVE-2010-3082
* debian/patches/01_disable_url_verify_regression_tests.diff:
  - updated to disable another test that fails without internet connection
  - patch based on work by Kai Kasurinen and Krzysztof Klimonda
* debian/control: don't Build-Depends on locales-all, which doesn't exist
  in maverick

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
.. _intro-tutorial01:
2
 
 
3
1
=====================================
4
2
Writing your first Django app, part 1
5
3
=====================================
14
12
    * A public site that lets people view polls and vote in them.
15
13
    * An admin site that lets you add, change and delete polls.
16
14
 
17
 
We'll assume you have :ref:`Django installed <intro-install>` already. You can
 
15
We'll assume you have :doc:`Django installed </intro/install>` already. You can
18
16
tell Django is installed by running the Python interactive interpreter and
19
17
typing ``import django``. If that command runs successfully, with no errors,
20
18
Django is installed.
47
45
   you try to run ``django-admin.py startproject``. This is because, on
48
46
   Unix-based systems like OS X, a file must be marked as "executable" before it
49
47
   can be run as a program. To do this, open Terminal.app and navigate (using
50
 
   the ``cd`` command) to the directory where :ref:`django-admin.py
51
 
   <ref-django-admin>` is installed, then run the command
 
48
   the ``cd`` command) to the directory where :doc:`django-admin.py
 
49
   </ref/django-admin>` is installed, then run the command
52
50
   ``chmod +x django-admin.py``.
53
51
 
54
52
.. note::
58
56
    ``django`` (which will conflict with Django itself) or ``test`` (which
59
57
    conflicts with a built-in Python package).
60
58
 
61
 
:ref:`django-admin.py <ref-django-admin>` should be on your system path if you
 
59
:doc:`django-admin.py </ref/django-admin>` should be on your system path if you
62
60
installed Django via ``python setup.py``. If it's not on your path, you can find
63
61
it in ``site-packages/django/bin``, where ```site-packages``` is a directory
64
 
within your Python installation. Consider symlinking to :ref:`django-admin.py
65
 
<ref-django-admin>` from some place on your path, such as
 
62
within your Python installation. Consider symlinking to :doc:`django-admin.py
 
63
</ref/django-admin>` from some place on your path, such as
66
64
:file:`/usr/local/bin`.
67
65
 
68
66
.. admonition:: Where should this code live?
93
91
 
94
92
    * :file:`manage.py`: A command-line utility that lets you interact with this
95
93
      Django project in various ways. You can read all the details about
96
 
      :file:`manage.py` in :ref:`ref-django-admin`.
 
94
      :file:`manage.py` in :doc:`/ref/django-admin`.
97
95
 
98
96
    * :file:`settings.py`: Settings/configuration for this Django project.
99
 
      :ref:`topics-settings` will tell you all about how settings work.
 
97
      :doc:`/topics/settings` will tell you all about how settings work.
100
98
 
101
99
    * :file:`urls.py`: The URL declarations for this Django project; a "table of
102
100
      contents" of your Django-powered site. You can read more about URLs in
103
 
      :ref:`topics-http-urls`.
 
101
      :doc:`/topics/http/urls`.
104
102
 
105
103
.. _more about packages: http://docs.python.org/tutorial/modules.html#packages
106
104
 
473
471
be called as often as you like, and it will only ever create the tables that
474
472
don't exist.
475
473
 
476
 
Read the :ref:`django-admin.py documentation <ref-django-admin>` for full
 
474
Read the :doc:`django-admin.py documentation </ref/django-admin>` for full
477
475
information on what the ``manage.py`` utility can do.
478
476
 
479
477
Playing with the API
508
506
    set the ``DJANGO_SETTINGS_MODULE`` environment variable to
509
507
    ``mysite.settings``.
510
508
 
511
 
    For more information on all of this, see the :ref:`django-admin.py
512
 
    documentation <ref-django-admin>`.
 
509
    For more information on all of this, see the :doc:`django-admin.py
 
510
    documentation </ref/django-admin>`.
513
511
 
514
 
Once you're in the shell, explore the :ref:`database API <topics-db-queries>`::
 
512
Once you're in the shell, explore the :doc:`database API </topics/db/queries>`::
515
513
 
516
514
    >>> from mysite.polls.models import Poll, Choice # Import the model classes we just wrote.
517
515
 
570
568
   models and don't see any change in how they're represented, you're most
571
569
   likely using an old version of Django. (This version of the tutorial is
572
570
   written for the latest development version of Django.) If you're using a
573
 
   Subversion checkout of Django's development version (see :ref:`the
574
 
   installation docs <topics-install>` for more information), you shouldn't have
 
571
   Subversion checkout of Django's development version (see :doc:`the
 
572
   installation docs </topics/install>` for more information), you shouldn't have
575
573
   any problems.
576
574
 
577
575
   If you want to stick with an older version of Django, you'll want to switch
693
691
    >>> c = p.choice_set.filter(choice__startswith='Just hacking')
694
692
    >>> c.delete()
695
693
 
696
 
For more information on model relations, see :ref:`Accessing related objects
697
 
<ref-models-relations>`. For full details on the database API, see our
698
 
:ref:`Database API reference <topics-db-queries>`.
 
694
For more information on model relations, see :doc:`Accessing related objects
 
695
</ref/models/relations>`. For full details on the database API, see our
 
696
:doc:`Database API reference </topics/db/queries>`.
699
697
 
700
 
When you're comfortable with the API, read :ref:`part 2 of this tutorial
701
 
<intro-tutorial02>` to get Django's automatic admin working.
 
698
When you're comfortable with the API, read :doc:`part 2 of this tutorial
 
699
</intro/tutorial02>` to get Django's automatic admin working.