开发者

Understanding Django initial_data fixture

开发者 https://www.devze.com 2023-01-04 10:38 出处:网络
Question Why does Django automatically load the initial_data.json fixture when it\'s located inside the project directory but not located in one of the three specified locations that Django searches

Question

  • Why does Django automatically load the initial_data.json fixture when it's located inside the project directory but not located in one of the three specified locations that Django searches for fixtures?

Configuration Information

  1. I have not set the FIXTURE_DIRS setting in sett开发者_开发技巧ings.py
  2. Django 1.2.1

Django's Documentation Regarding Fixture Locations

The What's a "Fixture" section of Django's django-admin.py and manage.py documentation states:

Django will search in three locations for fixtures:

  1. In the fixtures directory of every installed application
  2. In any directory named in the FIXTURE_DIRS setting
  3. In the literal path named by the fixture

Django will load any and all fixtures it finds in these locations that match the provided fixture names.


initial_data is actually behaviour belonging to syncdb. What you are citing is the default places loaddata will look for when queried. initial_data.json is detected by the syncdb option and passed to loaddata. I agree it's a bit confusing, but you are actually mixing general fixture loading behaviour (loaddata) with automatic fixture loading behaviour (syncdb).

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消