Django

Code

Changeset 1904

Show
Ignore:
Timestamp:
01/10/06 23:07:38 (3 years ago)
Author:
adrian
Message:

magic-removal: Merged to [1903]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/magic-removal/AUTHORS

    r1879 r1904  
    8383    Luke Plant <http://lukeplant.me.uk/> 
    8484    plisk 
     85    Daniel Poelzleithner <http://poelzi.org/> 
    8586    Brian Ray <http://brianray.chipy.org/> 
    8687    Oliver Rutherfurd <http://rutherfurd.net/> 
  • django/branches/magic-removal/django/contrib/admin/media/css/global.css

    r1839 r1904  
    123123 
    124124/* FORM BUTTONS */ 
    125 input[type=submit], input[type=button], .submit-row input { border:1px solid #ccc; background:white url(../img/admin/nav-bg.gif) bottom repeat-x;
     125input[type=submit], input[type=button], .submit-row input { border:1px solid #ccc; background:white url(../img/admin/nav-bg.gif) bottom repeat-x; color:black;
    126126input[type=submit]:active, input[type=button]:active { background-image:url(../img/admin/nav-bg-reverse.gif); background-position:top; } 
    127127input[type=submit].default, .submit-row input.default { border:2px solid #5b80b2; padding:3px; background:white url(../img/admin/default-bg.gif) bottom repeat-x; font-weight:bold; color:white; } 
  • django/branches/magic-removal/django/core/formfields.py

    r1873 r1904  
    812812                t = t.replace(microsecond=int(part_list[1])) 
    813813            return t 
    814         except (ValueError, TypeError): 
     814        except (ValueError, TypeError, AttributeError): 
    815815            return None 
    816816    html2python = staticmethod(html2python) 
  • django/branches/magic-removal/django/core/management.py

    r1888 r1904  
    946946createcachetable.args = "[tablename]" 
    947947 
     948def run_shell(): 
     949    "Runs a Python interactive interpreter" 
     950    import code 
     951    code.interact() 
     952run_shell.args = '' 
     953 
    948954# Utilities for command-line script 
    949955 
     
    959965    'installperms': installperms, 
    960966    'runserver': runserver, 
     967    'shell': run_shell, 
    961968    'sql': get_sql_create, 
    962969    'sqlall': get_sql_all, 
     
    10391046        else: 
    10401047            action_mapping[action](username, email, password) 
    1041     elif action in ('init', 'init-minimal', 'validate'): 
     1048    elif action in ('init', 'init-minimal', 'shell', 'validate'): 
    10421049        action_mapping[action]() 
    10431050    elif action == 'inspectdb': 
  • django/branches/magic-removal/django/core/template/defaultfilters.py

    r1818 r1904  
    137137    """ 
    138138    from django.utils.text import wrap 
    139     return wrap(value, int(arg)) 
     139    return wrap(str(value), int(arg)) 
    140140 
    141141def ljust(value, arg): 
  • django/branches/magic-removal/docs/authentication.txt

    r1775 r1904  
    171171--------- 
    172172 
    173 **This only applies to the Django development version.** Previous versions, 
    174 such as Django 0.90, used simple MD5 hashes without password salts. 
     173Previous versions, such as Django 0.90, used simple MD5 hashes without password 
     174salts. 
    175175 
    176176The ``password`` field of a ``User`` object is a string in this format:: 
     
    315315is not anonymous. 
    316316 
    317 **New in the Django development version**: ``user_passes_test()`` takes an 
    318 optional ``login_url`` argument, which lets you specify the URL for your login 
    319 page (``/accounts/login/`` by default). 
     317``user_passes_test()`` takes an optional ``login_url`` argument, which lets you 
     318specify the URL for your login page (``/accounts/login/`` by default). 
    320319 
    321320Example in Python 2.3 syntax:: 
  • django/branches/magic-removal/docs/cache.txt

    r1818 r1904  
    4949                                    this is multi-process- and thread-safe. 
    5050 
    51     dummy:///                       **New in Django development version.** 
    52                                     Doesn't actually cache; just implements the 
     51    dummy:///                       Doesn't actually cache; just implements the 
    5352                                    cache backend interface and doesn't do 
    5453                                    anything. This is an easy way to turn off 
  • django/branches/magic-removal/docs/db-api.txt

    r1884 r1904  
    223223---------- 
    224224 
    225 **New in Django development version.** 
    226  
    227225By default, keyword argument queries are "AND"ed together. If you have more complex query  
    228226requirements (for example, you need to include an ``OR`` statement in your query), you need  
  • django/branches/magic-removal/docs/django-admin.txt

    r1518 r1904  
    77 
    88The ``django-admin.py`` script should be on your system path if you installed 
    9 Django via its setup.py utility. If it's not on your path, you can find it in 
     9Django via its ``setup.py`` utility. If it's not on your path, you can find it in 
    1010``site-packages/django/bin`` within your Python installation. Consider 
    1111symlinking to it from some place on your path, such as ``/usr/local/bin``. 
    1212 
     13In addition, ``manage.py`` is automatically created in each Django project. 
     14``manage.py`` is a thin wrapper around ``django-admin.py`` that takes care of 
     15two things for you before delegating to ``django-admin.py``: 
     16 
     17    * It puts your project's package on ``sys.path``. 
     18 
     19    * It sets the ``DJANGO_SETTINGS_MODULE`` environment variable so that it 
     20      points to your project's ``settings.py`` file. 
     21 
     22Generally, when working on a single Django project, it's easier to use 
     23``manage.py``. Use ``django-admin.py`` with ``DJANGO_SETTINGS_MODULE``, or the 
     24``--settings`` command line option, if you need to switch between multiple 
     25Django settings files. 
     26 
    1327Usage 
    1428===== 
    1529 
    1630``django-admin.py action [options]`` 
     31``manage.py action [options]`` 
    1732 
    1833``action`` should be one of the actions listed in this document. ``options``, 
     
    5570address and password. 
    5671 
    57 **New in Django development version:** You can specify 
    58 ``username email password`` on the command line, for convenient use in shell 
    59 scripts. Example:: 
     72You can specify ``username email password`` on the command line, for convenient 
     73use in shell scripts. Example:: 
    6074 
    6175    django-admin.py createsuperuser john john@example.com mypassword 
     
    212226``django-admin.py`` will use the DJANGO_SETTINGS_MODULE environment variable. 
    213227 
     228Note that this option is unnecessary in ``manage.py``, because it takes care of 
     229setting ``DJANGO_SETTINGS_MODULE`` for you. 
     230 
    214231--pythonpath 
    215232------------ 
     
    223240variable. 
    224241 
     242Note that this option is unnecessary in ``manage.py``, because it takes care of 
     243setting the Python path for you. 
     244 
    225245.. _import search path: http://diveintopython.org/getting_to_know_python/everything_is_an_object.html 
    226246 
  • django/branches/magic-removal/docs/email.txt

    r1810 r1904  
    119119=========================== 
    120120 
    121 **New in Django development version.** 
    122  
    123121`Header injection`_ is a security exploit in which an attacker inserts extra 
    124122e-mail headers to control the "To:" and "From:" in e-mail messages that your 
  • django/branches/magic-removal/docs/generic_views.txt

    r1775 r1904  
    130130                             template's context. 
    131131 
    132     ``processors``           **New in Django development version.** A tuple of 
    133                              processors to apply to the ``DjangoContext`` of 
    134                              this view's template. See the `DjangoContext docs`_ 
     132    ``processors``           A tuple of processors to apply to the 
     133                             ``DjangoContext`` of this view's template. See the 
     134                             `DjangoContext docs`_ 
    135135    =======================  ================================================== 
    136136 
     
    151151                                 Defaults to 15. 
    152152 
    153         ``allow_empty``          **New in Django development version.** 
    154                                  If ``False`` and there are no objects to display, 
     153        ``allow_empty``          If ``False`` and there are no objects to display, 
    155154                                 the view will raise a 404 instead of displaying 
    156155                                 an empty index page. ``False`` is default. 
  • django/branches/magic-removal/docs/request_response.txt

    r1873 r1904  
    152152      a mutable ``QueryDict`` (one that was created via ``copy()``). 
    153153 
    154     * ``__contains__(key)`` -- **New in Django development version.** Returns 
    155       ``True`` if the given key is set. This lets you do, e.g., 
    156       ``if "foo" in request.GET``. 
     154    * ``__contains__(key)`` -- Returns ``True`` if the given key is set. This 
     155      lets you do, e.g., ``if "foo" in request.GET``. 
    157156 
    158157    * ``get(key, default)`` -- Uses the same logic as ``__getitem__()`` above, 
     
    362361 
    363362``HttpResponsePermanentRedirect`` 
    364     **New in Django development version.*** 
    365  
    366363    Like ``HttpResponseRedirect``, but it returns a permanent redirect (HTTP 
    367364    status code 301) instead of a "found" redirect (status code 302). 
  • django/branches/magic-removal/docs/sessions.txt

    r1866 r1904  
    3131 
    3232    * ``__contains__(key)`` 
    33       **New in Django development version.** Example: ``'fav_color' in request.session`` 
     33      Example: ``'fav_color' in request.session`` 
    3434 
    3535    * ``__getitem__(key)`` 
     
    178178    request.session['foo']['bar'] = 'baz' 
    179179 
    180 **Only available in Django development version.** To change this default 
    181 behavior, set the ``SESSION_SAVE_EVERY_REQUEST`` setting  to ``True``. If 
    182 ``SESSION_SAVE_EVERY_REQUEST`` is ``True``, Django will save the session to the 
    183 database on every single request. 
     180To change this default behavior, set the ``SESSION_SAVE_EVERY_REQUEST`` setting 
     181to ``True``. If ``SESSION_SAVE_EVERY_REQUEST`` is ``True``, Django will save 
     182the session to the database on every single request. 
    184183 
    185184Note that the session cookie is only sent when a session has been created or 
     
    214213------------------- 
    215214 
    216 Default: ``'sessionid'`` (**Django development version.** Previous default was 
    217 ``'hotclub'``, which was deemed too pornish.) 
     215Default: ``'sessionid'`` 
    218216 
    219217The name of the cookie to use for sessions. This can be whatever you want. 
     
    223221 
    224222Default: ``False`` 
    225  
    226 **Only available in Django development version.** 
    227223 
    228224Whether to save the session data on every request. If this is ``False`` 
  • django/branches/magic-removal/docs/settings.txt

    r1810 r1904  
    526526------------------- 
    527527 
    528 Default: ``'sessionid'`` (**Django development version.** Previous default was 
    529 ``'hotclub'``, which was deemed too pornish.) 
     528Default: ``'sessionid'`` 
    530529 
    531530The name of the cookie to use for sessions. This can be whatever you want. 
     
    557556    "django.core.context_processors.i18n") 
    558557 
    559 **Only available in Django development version.** 
    560  
    561558A tuple of callables that are used to populate the context in ``DjangoContext``. 
    562559These callables take a request object as their argument and return a dictionary 
     
    567564 
    568565Default: ``False`` 
    569  
    570 **Only available in Django development version.** 
    571566 
    572567A boolean that turns on/off template debug mode. If this is ``True``, the fancy 
  • django/branches/magic-removal/docs/templates_python.txt

    r1873 r1904  
    283283        }, [ip_address_processor]) 
    284284 
    285 Note: The concept of template-context processors is new in the Django 
    286 development version. In Django 0.90, ``DjangoContext`` automatically populates 
    287 the context with all of the values explained below, but it's not possible to 
    288 add and remove processors. 
    289  
    290285Here's what each of the default processors does: 
    291286 
     
    541536------------------------------- 
    542537 
    543 **This section applies to the Django development version.** 
    544  
    545538Custom filters are just Python functions that take one or two arguments: 
    546539 
     
    601594Writing custom template tags 
    602595---------------------------- 
    603  
    604 **This section applies to the Django development version.** 
    605596 
    606597Tags are more complex than filters, because tags can do anything. 
  • django/branches/magic-removal/docs/templates.txt

    r1525 r1904  
    279279area in your admin to find the list of custom libraries in your installation. 
    280280 
    281 **New in Django development version:** The ``{% load %}`` tag can take multiple 
    282 library names, separated by spaces. Example:: 
     281The ``{% load %}`` tag can take multiple library names, separated by spaces. 
     282Example:: 
    283283 
    284284    {% load comments i18n %} 
     
    500500include 
    501501~~~~~~~ 
    502  
    503 **Only available in Django development version.** 
    504502 
    505503Loads a template and renders it with the current context. This is a way of 
  • django/branches/magic-removal/docs/tutorial01.txt

    r1687 r1904  
    3535.. admonition:: Where should this code live? 
    3636 
    37    If your background is in PHP, you're probably used to putting code under the 
    38    Web server's document root (in a place such as ``/var/www``). With Django, 
    39    you don't do that. It's not a good idea to put any of this Python code within 
    40    your Web server's document root, because it risks the possibility that 
    41    people may be able to view your code over the Web. That's not good for 
    42    security. 
    43  
    44    Put your code in some directory **outside** of the document root, such as 
    45    ``/home/mycode``. 
     37    If your background is in PHP, you're probably used to putting code under the 
     38    Web server's document root (in a place such as ``/var/www``). With Django, 
     39    you don't do that. It's not a good idea to put any of this Python code within 
     40    your Web server's document root, because it risks the possibility that 
     41    people may be able to view your code over the Web. That's not good for 
     42    security. 
     43 
     44    Put your code in some directory **outside** of the document root, such as 
     45    ``/home/mycode``. 
    4646 
    4747A project is a collection of settings for an instance of Django -- including 
     
    5151    myproject/ 
    5252        __init__.py 
    53         apps/ 
    54             __init__.py 
     53        manage.py 
    5554        settings.py 
    5655        urls.py 
    5756 
    58 First, edit ``myproject/settings.py``. It's a normal Python module with 
    59 module-level variables representing Django settings. Edit the file and change 
    60 these settings to match your database's connection parameters: 
     57These files are: 
     58 
     59    * ``manage.py``: A command-line utility that lets you interact with this 
     60      Django project in various ways. 
     61    * ``settings.py``: Settings/configuration for this Django project. 
     62    * ``urls.py``: The URL declarations for this Django project; a "table of 
     63      contents" of your Django-powered site. 
     64 
     65The development server 
     66---------------------- 
     67 
     68Change into the ``myproject`` directory, if you haven't already, and run the 
     69command ``python manage.py runserver``. You'll see the following output on the 
     70command line:: 
     71 
     72    Validating models... 
     73    0 errors found. 
     74 
     75    Starting server on port 8000 with settings module 'myproject.settings'. 
     76    Go to http://127.0.0.1:8000/ for Django. 
     77    Quit the server with CONTROL-C (Unix) or CTRL-BREAK (Windows). 
     78 
     79You've started the Django development server, a lightweight, pure-Python Web 
     80server that builds on the BaseHTTPServer included in Python's standard library. 
     81We've included this with Django so you can develop things rapidly, without 
     82having to deal with configuring Apache until you're ready for production. 
     83 
     84DON'T use this server in anything resembling a production environment. It's 
     85intended only for use while developing. 
     86 
     87.. admonition:: Changing the port 
     88 
     89    By default, the ``runserver`` command starts the development server on port 
     90    8000. If you want to change the server's port, pass it as a command-line 
     91    argument:: 
     92 
     93        python manage.py runserver 8080 
     94 
     95Now that the server's running, visit http://127.0.0.1:8000/ with your Web 
     96browser. You'll see a "Welcome to Django" page, in pleasant, light-blue pastel. 
     97It worked! 
     98 
     99Database setup 
     100-------------- 
     101 
     102Now, edit ``settings.py``. It's a normal Python module with module-level 
     103variables representing Django settings. Change these settings to match your 
     104database's connection parameters: 
    61105 
    62106    * ``DATABASE_ENGINE`` -- Either 'postgresql', 'mysql' or 'sqlite3'. 
    63107      More coming soon. 
    64108    * ``DATABASE_NAME`` -- The name of your database, or the full (absolute) 
    65       path to the database file if you're using sqlite. 
    66     * ``DATABASE_USER`` -- Your database username (not used for sqlite). 
    67     * ``DATABASE_PASSWORD`` -- Your database password (not used for sqlite). 
     109      path to the database file if you're using SQLite. 
     110    * ``DATABASE_USER`` -- Your database username (not used for SQLite). 
     111    * ``DATABASE_PASSWORD`` -- Your database password (not used for SQLite). 
    68112    * ``DATABASE_HOST`` -- The host your database is on. Leave this as an 
    69113      empty string if your database server is on the same physical machine 
    70       (not used for sqlite). 
     114      (not used for SQLite). 
    71115 
    72116.. admonition:: Note 
     
    76120    database's interactive prompt. 
    77121 
    78 Now, take a second to make sure ``myproject`` is on your Python path. You 
    79 can do this by copying ``myproject`` to Python's ``site-packages`` directory, 
    80 or you can do it by altering the ``PYTHONPATH`` environment variable. See the 
    81 `Python path documentation`_ for more information. If you opt to set the 
    82 ``PYTHONPATH`` environment variable, note that you'll need to set it to the 
    83 *parent* directory of ``myproject``. (You can test this by typing 
    84 "import myproject" into the Python interactive prompt.) 
    85  
    86 Run the following command:: 
    87  
    88     django-admin.py init --settings=myproject.settings 
    89  
    90 The ``django-admin.py`` utility generally needs to know which settings module 
    91 you're using. Here, we're doing that by specifying ``settings=`` on the command 
    92 line, but that can get tedious. If you don't want to type ``settings=`` each 
    93 time, you can set the ``DJANGO_SETTINGS_MODULE`` environment variable. Here's 
    94 how you do that in the Bash shell on Unix:: 
    95  
    96     export DJANGO_SETTINGS_MODULE=myproject.settings 
    97  
    98 On Windows, you'd use ``set`` instead:: 
    99  
    100     set DJANGO_SETTINGS_MODULE=myproject.settings 
    101  
    102 If you don't see any errors after running ``django-admin.py init``, you know it 
    103 worked. That command initialized your database with Django's core database 
    104 tables. If you're interested, run the command-line client for your database and 
    105 type ``\dt`` (PostgreSQL), ``SHOW TABLES;`` (MySQL), or ``.schema`` (SQLite) to 
    106 display the tables. 
    107  
    108 .. _`Python path documentation`: http://docs.python.org/tut/node8.html#SECTION008110000000000000000 
     122Run the following command to initialize your database with Django's core 
     123database tables:: 
     124 
     125    python manage.py init 
     126 
     127If you don't see any errors, it worked. 
     128 
     129If you're interested, run the command-line client for your database and type 
     130``\dt`` (PostgreSQL), ``SHOW TABLES;`` (MySQL), or ``.schema`` (SQLite) to 
     131display the tables Django created. 
     132 
     133.. admonition:: About those database tables 
     134 
     135    The tables created by ``manage.py init`` are for sessions, authentication 
     136    and other features Django provides. The next release of Django will have 
     137    a "lite" version of the ``init`` command that won't install any database 
     138    tables if you don't want them. 
    109139 
    110140Creating models 
     
    112142 
    113143Now that your environment -- a "project" -- is set up, you're set to start 
    114 doing work. (You won't have to take care of this boring administrative stuff 
     144doing work. (You won't have to take care of that boring administrative stuff 
    115145again.) 
    116146 
    117 Each application you write in Django -- e.g., a weblog system, a database of 
    118 public records or a simple poll app -- consists of a Python package, somewhere 
    119 on your Python path, that follows a certain convention. Django comes with a 
     147Each application you write in Django consists of a Python package, somewhere 
     148on your `Python path`_, that follows a certain convention. Django comes with a 
    120149utility that automatically generates the basic directory structure of an app, 
    121150so you can focus on writing code rather than creating directories. 
    122151 
    123 In this tutorial, we'll create our poll app in the ``myproject/apps`` 
    124 directory, for simplicity. As a consequence, the app will be coupled to the 
    125 project -- that is, Python code within the poll app will refer to 
    126 ``myproject.apps.polls``. Later in this tutorial, we'll discuss decoupling 
    127 your apps for distribution. 
    128  
    129 To create your app, change into the ``myproject/apps`` directory and type this 
    130 command:: 
    131  
    132     django-admin.py startapp polls 
    133  
    134 (From now on, this tutorial will leave out the ``--settings`` parameter and 
    135 will assume you've either set your ``DJANGO_SETTINGS_MODULE`` environment 
    136 variable or included the ``--settings`` option in your call to the command.) 
    137  
    138 That'll create a directory structure like this:: 
     152.. admonition:: Projects vs. apps 
     153 
     154    What's the difference between a project and an app? An app is a Web 
     155    application that does something -- e.g., a weblog system, a database of 
     156    public records or a simple poll app. A project is a collection of 
     157    configuration and apps for a particular Web site. A project can contain 
     158    multiple apps. An app can be in multiple projects. 
     159 
     160In this tutorial, we'll create our poll app in the ``myproject`` directory, 
     161for simplicity. As a consequence, the app will be coupled to the project -- 
     162that is, Python code within the poll app will refer to ``myproject.polls``. 
     163Later in this tutorial, we'll discuss decoupling your apps for distribution. 
     164 
     165To create your app, make sure you're in the ``myproject`` directory and type 
     166this command:: 
     167 
     168    python manage.py startapp polls 
     169 
     170That'll create a directory ``polls``, which is laid out like this:: 
    139171 
    140172    polls/ 
     
    202234database relationships: many-to-ones, many-to-manys and one-to-ones. 
    203235 
     236.. _`Python path`: http://docs.python.org/tut/node8.html#SECTION008110000000000000000 
    204237.. _DRY Principle: http://c2.com/cgi/wiki?DontRepeatYourself 
    205238 
     
    210243is able to: 
    211244 
    212 * Create a database schema (``CREATE TABLE`` statements) for this app. 
    213 * Create a Python database-access API for accessing Poll and Choice objects. 
     245    * Create a database schema (``CREATE TABLE`` statements) for this app. 
     246    * Create a Python database-access API for accessing Poll and Choice objects. 
    214247 
    215248But first we need to tell our project that the ``polls`` app is installed. 
     
    217250.. admonition:: Philosophy 
    218251 
    219    Django apps are "pluggable": You can use an app in multiple 
    220    projects, and you can distribute apps, because they don't have to be tied to 
    221    a given Django installation. 
    222  
    223 Edit the myproject/settings.py file again, and change the ``INSTALLED_APPS`` 
    224 setting to include the string "myproject.apps.polls". So it'll look like this:: 
     252    Django apps are "pluggable": You can use an app in multiple projects, and 
     253    you can distribute apps, because they don't have to be tied to a given 
     254    Django installation. 
     255 
     256Edit the ``settings.py`` file again, and change the ``INSTALLED_APPS`` setting 
     257to include the string ``'myproject.polls'``. So it'll look like this:: 
    225258 
    226259    INSTALLED_APPS = ( 
    227         'myproject.apps.polls', 
     260        'myproject.polls', 
    228261    ) 
    229262 
    230 (Don't forget the trailing comma because of Python's rules about single-value 
    231 tuples.) 
    232  
    233 Now Django knows myproject includes the polls app. Let's run another command:: 
    234  
    235     django-admin.py sql polls 
    236  
    237 (Note that it doesn't matter which directory you're in when you run this command.) 
     263(Don't forget the trailing comma, because of Python's rule about single-value 
     264tuples: Without a trailing comma, Python wouldn't know this was a tuple.) 
     265 
     266Now Django knows ``myproject`` includes the ``polls`` app. Let's run another command:: 
     267 
     268    python manage.py sql polls 
    238269 
    239270You should see the following (the CREATE TABLE SQL statements for the polls app):: 
     
    256287 
    257288    * Table names are automatically generated by combining the name of the app 
    258       (polls) with a plural version of the object name (polls and choices). (You 
    259       can override this behavior.) 
     289      (``polls``) with a plural version of the object name (polls and choices). 
     290      (You can override this behavior.) 
    260291 
    261292    * Primary keys (IDs) are added automatically. (You can override this, too.) 
     
    266297    * The foreign key relationship is made explicit by a ``REFERENCES`` statement. 
    267298 
    268     * It's tailored to the database you're using, so database-specific field types 
    269       such as ``auto_increment`` (MySQL), ``serial`` (PostgreSQL), or ``intege
    270       primary key`` (SQLite) are handled for you automatically. Same goes for 
    271       quoting of field names -- e.g., using double quotes or single quotes. Th
    272       author of this tutorial runs PostgreSQL, so the example output is in 
    273       PostgreSQL syntax. 
     299    * It's tailored to the database you're using, so database-specific field 
     300      types such as ``auto_increment`` (MySQL), ``serial`` (PostgreSQL), o
     301      ``integer primary key`` (SQLite) are handled for you automatically. Same 
     302      goes for quoting of field names -- e.g., using double quotes or singl
     303      quotes. The author of this tutorial runs PostgreSQL, so the example 
     304      output is inPostgreSQL syntax. 
    274305 
    275306If you're interested, also run the following commands: 
    276307 
    277     * ``django-admin.py sqlinitialdata polls`` -- Outputs the initial-data 
     308    * ``python manage.py sqlinitialdata polls`` -- Outputs the initial-data 
    278309      inserts required for Django's admin framework. 
    279310 
    280     * ``django-admin.py sqlclear polls`` -- Outputs the necessary ``DROP 
     311    * ``python manage.py sqlclear polls`` -- Outputs the necessary ``DROP 
    281312      TABLE`` statements for this app, according to which tables already exist 
    282313      in your database (if any). 
    283314 
    284     * ``django-admin.py sqlindexes polls`` -- Outputs the ``CREATE INDEX`` 
     315    * ``python manage.py sqlindexes polls`` -- Outputs the ``CREATE INDEX`` 
    285316      statements for this app. 
    286317 
    287     * ``django-admin.py sqlall polls`` -- A combination of 'sql' and 
     318    * ``python manage.py sqlall polls`` -- A combination of 'sql' and 
    288319      'sqlinitialdata'. 
    289320 
     
    294325automatically:: 
    295326 
    296     django-admin.py install polls 
     327    python manage.py install polls 
    297328 
    298329Behind the scenes, all that command does is take the output of 
    299 ``django-admin.py sqlall polls`` and execute it in the database pointed-to by 
     330``python manage.py sqlall polls`` and execute it in the database pointed-to by 
    300331your Django settings file. 
    301332 
    302 Read the `django-admin.py documentation`_ for full information on what this 
    303 utility can do. 
     333Read the `django-admin.py documentation`_ for full information on what the 
     334``manage.py`` utility can do. 
    304335 
    305336.. _django-admin.py documentation: http://www.djangoproject.com/documentation/django_admin/ 
     
    308339==================== 
    309340 
    310 Now, make sure your DJANGO_SETTINGS_MODULE environment variable is set (as 
    311 explained above), and open the Python interactive shell to play around with the 
    312 free Python API Django gives you:: 
     341Now, let's hop into the interactive Python shell and play around with the free 
     342API Django gives you. To invoke the Python shell, use this command:: 
     343 
     344    python manage.py shell 
     345 
     346We're using this instead of simply typing "python", because ``manage.py`` sets 
     347up the project's environment for you. "Setting up the environment" involves two 
     348things: 
     349 
     350    * Putting ``myproject`` on ``sys.path``. For flexibility, several pieces of 
     351      Django refer to projects in Python dotted-path notation (e.g. 
     352      ``'myproject.polls.models'``). In order for this to work, the 
     353      ``myproject`` package has to be on ``sys.path``. 
     354 
     355      We've already seen one example of this: the ``INSTALLED_APPS`` setting is 
     356      a list of packages in dotted-path notation. 
     357 
     358    * Setting the ``DJANGO_SETTINGS_MODULE`` environment variable, which gives 
     359      Django the path to your ``settings.py`` file. 
     360 
     361.. admonition:: Bypassing manage.py 
     362 
     363    If you'd rather not use ``manage.py``, no problem. Just make sure 
     364    ``myproject`` is at the root level on the Python path (i.e., 
     365    ``import myproject`` works) and set the ``DJANGO_SETTINGS_MODULE`` 
     366    environment variable to ``myproject.settings``. 
     367 
     368    For more information on all of this, see the `django-admin.py documentation`_. 
     369 
     370Once you're in the shell, explore the database API:: 
    313371 
    314372    # Modules are dynamically created within django.models. 
     
    327385    >>> p.save() 
    328386 
    329     # Now it has an ID. 
     387    # Now it has an ID. Note that this might say "1L" instead of "1", depending 
     388    # on which database you're using. That's no biggie; it just means your 
     389    # database backend prefers to return integers as Python long integer 
     390    # objects. 
    330391    >>> p.id 
    331392    1 
     
    376437``datetime`` module from the Python standard library. 
    377438 
    378 Let's jump back into the Python interactive shell:: 
     439Let's jump back into the Python interactive shell by running 
     440``python manage.py shell`` again:: 
    379441 
    380442    >>> from django.models.polls import polls, choices 
  • django/branches/magic-removal/docs/tutorial02.txt

    r1754 r1904  
    3232 
    3333    * Add ``"django.contrib.admin"`` to your ``INSTALLED_APPS`` setting. 
    34     * Run the command ``django-admin.py install admin``. This will create an 
     34    * Run the command ``python manage.py install admin``. This will create an 
    3535      extra database table that the admin needs. 
    3636    * Edit your ``myproject/urls.py`` file and uncomment the line below 
     
    4444Run the following command to create a superuser account for your admin site:: 
    4545 
    46     django-admin.py createsuperuser --settings=myproject.settings 
     46    python manage.py createsuperuser 
    4747 
    4848The script will prompt you for a username, e-mail address and password (twice). 
     
    5151============================ 
    5252 
    53 To make things easy, Django comes with a pure-Python Web server that builds on 
    54 the BaseHTTPServer included in Python's standard library. Let's start the 
    55 server and explore the admin site. 
    56  
    57 Just run the following command to start the server:: 
    58  
    59     django-admin.py runserver --settings=myproject.settings 
    60  
    61 It'll start a Web server running locally -- on port 8000, by default. If you 
    62 want to change the server's port, pass it as a command-line argument:: 
    63  
    64     django-admin.py runserver 8080 --settings=myproject.settings 
    65  
    66 DON'T use this server in anything resembling a production environment. It's 
    67 intended only for use while developing. 
     53Let's start the development server and explore the admin site. 
     54 
     55Recall from Tutorial 1 that you start the development server like so:: 
     56 
     57    python manage.py runserver 
    6858 
    6959Now, open a Web browser and go to "/admin/" on your local domain -- e.g., 
     
    9282But where's our poll app? It's not displayed on the admin index page. 
    9383 
    94 Just one thing to do: We need to specify in the ``polls.Poll`` model that Poll 
    95 objects have an admin interface. Edit the ``myproject/apps/polls/models/polls.py`` 
     84Just one thing to do: We need to specify in the ``Poll`` model that ``Poll`` 
     85objects have an admin interface. Edit the ``myproject/polls/models/polls.py`` 
    9686file and make the following change to add an inner ``Meta`` class with an 
    9787``admin`` attribute:: 
     
    10292            admin = meta.Admin() 
    10393 
    104 The ``class Meta`` contains all non-field metadata about this model. 
     94The ``class Meta`` contains all `non-field metadata`_ about this model. 
    10595 
    10696Now reload the Django admin page to see your changes. Note that you don't have 
    10797to restart the development server -- it auto-reloads code. 
     98 
     99.. _non-field metadata: http://www.djangoproject.com/documentation/model_api/#meta-options 
    108100 
    109101Explore the free admin functionality 
     
    217209====================== 
    218210 
    219 OK, we have our Poll admin page. But a ``Poll`` has multiple ``Choices``, and the admin 
    220 page doesn't display choices. 
     211OK, we have our Poll admin page. But a ``Poll`` has multiple ``Choices``, and 
     212the admin page doesn't display choices. 
    221213 
    222214Yet. 
    223215 
    224 In this case, there are two ways to solve this problem. The first is to give 
    225 the ``Choice`` model its own ``admin`` attribute, just as we did with ``Poll``. 
    226 Here's what that would look like:: 
     216There are two ways to solve this problem. The first is to give the ``Choice`` 
     217model its own ``admin`` attribute, just as we did with ``Poll``. Here's what 
     218that would look like:: 
    227219 
    228220    class Choice(meta.Model): 
     
    238230 
    239231In that form, the "Poll" field is a select box containing every poll in the 
    240 database. In our case, only one poll exists at this point. 
     232database. Django knows that a ``ForeignKey`` should be represented in the admin 
     233as a ``<select>`` box. In our case, only one poll exists at this point. 
    241234 
    242235Also note the "Add Another" link next to "Poll." Every object with a ForeignKey 
     
    364357That adds a search box at the top of the change list. When somebody enters 
    365358search terms, Django will search the ``question`` field. You can use as many 
    366 fields as you'd like -- although because it uses a LIKE query behind the 
     359fields as you'd like -- although because it uses a ``LIKE`` query behind the 
    367360scenes, keep it reasonable, to keep your database happy. 
    368361 
     
    445438 
    446439Django offers another shortcut in this department. Run the command 
    447 ``django-admin.py adminindex polls`` to get a chunk of template code for 
     440``python manage.py adminindex polls`` to get a chunk of template code for 
    448441inclusion in the admin index template. It's a useful starting point. 
    449442 
  • django/branches/magic-removal/docs/tutorial03.txt

    r1291 r1904  
    6363For more details on URLconfs, see the `URLconf documentation`_. 
    6464 
    65 When you ran ``django-admin.py startproject myproject`` at the beginning of 
     65When you ran ``python manage.py startproject myproject`` at the beginning of 
    6666Tutorial 1, it created a default URLconf in ``myproject/urls.py``. It also 
    6767automatically set your ``ROOT_URLCONF`` setting to point at that file:: 
     
    7474 
    7575    urlpatterns = patterns('', 
    76         (r'^polls/$', 'myproject.apps.polls.views.index'), 
    77         (r'^polls/(?P<poll_id>\d+)/$', 'myproject.apps.polls.views.detail'), 
    78         (r'^polls/(?P<poll_id>\d+)/results/$', 'myproject.apps.polls.views.results'), 
    79         (r'^polls/(?P<poll_id>\d+)/vote/$', 'myproject.apps.polls.views.vote'), 
     76        (r'^polls/$', 'myproject.polls.views.index'), 
     77        (r'^polls/(\d+)/$', 'myproject.polls.views.detail'), 
     78        (r'^polls/(\d+)/results/$', 'myproject.polls.views.results'), 
     79        (r'^polls/(\d+)/vote/$', 'myproject.polls.views.vote'), 
    8080    ) 
    8181 
     
    8484by the ``ROOT_URLCONF`` setting. It finds the variable named ``urlpatterns`` 
    8585and traverses the regular expressions in order. When it finds a regular 
    86 expression that matches -- ``r'^polls/(?P<poll_id>\d+)/$'`` -- it loads the 
    87 associated Python package/module: ``myproject.apps.polls.views.detail``. That 
    88 corresponds to the function ``detail()`` in ``myproject/apps/polls/views.py``. 
     86expression that matches -- ``r'^polls/(\d+)/$'`` -- it loads the 
     87associated Python package/module: ``myproject.polls.views.detail``. That 
     88corresponds to the function ``detail()`` in ``myproject/polls/views.py``. 
    8989Finally, it calls that ``detail()`` function like so:: 
    9090 
    9191    detail(request=<HttpRequest object>, poll_id='23') 
    9292 
    93 The ``poll_id='23'`` part comes from ``(?P<poll_id>\d+)``. Using 
    94 ``(?P<name>pattern)`` "captures" the text matched by ``pattern`` and sends i
    95 as a keyword argument to the view function. 
     93The ``poll_id='23'`` part comes from ``(\d+)``. Using parenthesis around a 
     94pattern "captures" the text matched by that pattern and sends it as an argumen
     95to the view function. 
    9696 
    9797Because the URL patterns are regular expressions, there really is no limit on 
     
    100100something like this:: 
    101101 
    102     (r'^polls/latest\.php$', 'myproject.apps.polls.views.index'), 
     102    (r'^polls/latest\.php$', 'myproject.polls.views.index'), 
    103103 
    104104But, don't do that. It's silly. 
     
    129129Fire up the Django development Web server:: 
    130130 
    131     django-admin.py runserver --settings=myproject.settings&nb