Changes between Version 9 and Version 10 of Fixtures


Ignore:
Timestamp:
Feb 14, 2014, 7:51:14 AM (10 years ago)
Author:
stommepoes@…
Comment:

Some grammar, and off->of

Legend:

Unmodified
Added
Removed
Modified
  • Fixtures

    v9 v10  
    11= Fixtures =
    22
    3 ''It's a very simple example, please, read something more complex if you need.''
     3''This is a very simple example. Please read something more complex if you need.''
    44
    55Fixtures are very powerful to play with your database sample data during development process.
    66After each '''python manage.py reset <myapp>''' command you need to populate database with sample data again and again using admin interface. It's quite boring, isn't it?
    77With fixtures our life became more comfortable and easy. Look at this example.
    8 Lets imagine that you have some data in db, so we can dump it. Even if your models have ForeignKeys or any kind of *To* relations.
     8Lets imagine that you have some data in db. We can dump it, even if your models have ForeignKeys or any kind of *To* relations.
    99
    1010First we need to define fixtures dir in settings file:
     
    4747== Fixture loading ==
    4848
    49 The location where Django loads a fixture from might seem unintuitive. As with template files the fixtures off all applications in a project share the same namespace. If you follow [source:django/trunk/django/core/management/commands/loaddata.py?rev=9770#L79 loaddata.py] you see that Django searches for {{{ *appnames*/fixtures }}} and {{{ settings.FIXTURE_DIRS }}}  and loads the first match. So if you use names like {{{ testdata.json }}} for your fixtures you must make sure that no other active application uses a fixture with the same name. If not, you can never be sure what fixtures you actually load.
     49The location where Django loads a fixture from might seem unintuitive. As with template files, the fixtures of all applications in a project share the same namespace. If you follow [source:django/trunk/django/core/management/commands/loaddata.py?rev=9770#L79 loaddata.py] you see that Django searches for {{{ *appnames*/fixtures }}} and {{{ settings.FIXTURE_DIRS }}}  and loads the first match. So if you use names like {{{ testdata.json }}} for your fixtures you must make sure that no other active application uses a fixture with the same name. If not, you can never be sure what fixtures you actually load.
    5050
    5151Therefore it is suggested that you prefix your fixtures with the application names, e.g. {{{ myapp/fixtures/myapp_testdata.json }}}.
Back to Top