Django

Code

Changeset 5912

Show
Ignore:
Timestamp:
08/16/07 18:05:00 (2 years ago)
Author:
adrian
Message:

Added 'django-admin.py testserver' command and docs

Files:

Legend:

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

    r5692 r5912  
    236236reset [appname appname ...] 
    237237--------------------------- 
     238 
    238239Executes the equivalent of ``sqlreset`` for the given appnames. 
    239240 
     
    427428Discover and run tests for all installed models.  See `Testing Django applications`_ for more information. 
    428429 
    429 .. _testing django applications: ../testing/ 
     430.. _testing Django applications: ../testing/ 
     431 
     432testserver [fixture fixture ...] 
     433-------------------------------- 
     434 
     435**New in Django development version** 
     436 
     437Runs a Django development server (as in ``runserver``) using data from the 
     438given fixture(s). 
     439 
     440For example, this command:: 
     441 
     442    django-admin.py testserver mydata.json 
     443 
     444...would perform the following steps: 
     445 
     446    1. Create a test database, as described in `testing Django applications`_. 
     447    2. Populate the test database with fixture data from the given fixtures. 
     448       (For more on fixtures, see the documentation for ``loaddata`` above.) 
     449    3. Runs the Django development server (as in ``runserver``), pointed at 
     450       this newly created test database instead of your production database. 
     451 
     452This is useful in a number of ways: 
     453 
     454    * When you're writing `unit tests`_ of how your views act with certain 
     455      fixture data, you can use ``testserver`` to interact with the views in 
     456      a Web browser, manually. 
     457 
     458    * Let's say you're developing your Django application and have a "pristine" 
     459      copy of a database that you'd like to interact with. You can dump your 
     460      database to a fixture (using the ``dumpdata`` command, explained above), 
     461      then use ``testserver`` to run your Web application with that data. With 
     462      this arrangement, you have the flexibility of messing up your data 
     463      in any way, knowing that whatever data changes you're making are only 
     464      being made to a test database. 
     465 
     466Note that this server can only run on the default port on localhost; it does 
     467not yet accept a ``host`` or ``port`` parameter. 
     468 
     469.. _unit tests: ../testing/ 
    430470 
    431471validate