Changes between Version 3 and Version 4 of Fixtures


Ignore:
Timestamp:
08/16/09 13:41:55 (6 years ago)
Author:
md@…
Comment:

Hints about Fixture loading paths

Legend:

Unmodified
Added
Removed
Modified
  • Fixtures

    v3 v4  
    1 == Fixtures ==
     1= Fixtures =
    22
    33''It is very simple example, please, read something more complex if you need.''
     
    4545}}}
    4646
     47== Fixture loading ==
     48
     49The 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 sour that no other active application uses a fixture with the same name. If not, you can never be sure what fixtures you actually load.
     50
     51Therefore it is suggested that you prefix your fixtures wit the application names, e.g. {{{ myapp/fixtures/myapp_testdata.json }}}.
     52
     53
    4754Links:
    4855[http://en.wikipedia.org/wiki/JSON]
Back to Top