loaddata can load fixture data multiple times, if specified with absolute pathname
|Reported by:||Owned by:||nobody|
|Severity:||Keywords:||loaddata absolute pathname|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Attached patch includes a regression test that demonstrates issue, along with a proposed fix (for review).
The situation can arise if a project has a test fixture that is maintained outside of the project structure. An attempt to load the fixture with an absolute path, e.g.
python manage.py loaddata /path/to/fixture
will work, but consumes more time and memory than necessary, since the fixture data will be loaded once for every fixture directory in a project (in either an installed application or FIXTURE_DIRS).
This effect can be observed in the count of objects and fixtures that are reported by the loaddata command. Setting '--verbosity=2' makes it more apparent.