Opened 10 years ago
Closed 10 years ago
#23468 closed Bug (fixed)
fixtures are imported twice with duplicate FIXTURE_DIRS
Reported by: | karyon | Owned by: | Konrad Świat |
---|---|---|---|
Component: | Core (Management commands) | Version: | 1.6 |
Severity: | Normal | Keywords: | |
Cc: | konrad.swiat@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
when listing a fixture dir two times in FIXTURE_DIRS, or listing a directory there that is already a default fixture dir of an app, fixtures in these directories are imported twice when running loaddata.
in my project someone accidentally added a default fixture dir to the FIXTURE_DIRS, and it took us a while to figure out why things were imported twice.
on a side node, if fixtures of the same name are in different directories, there are all imported, as opposed to when they are in the same directory (with different extensions). is this intended?
Change History (12)
comment:1 by , 10 years ago
Component: | Uncategorized → Core (Management commands) |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 10 years ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
Work in progress:
https://github.com/kswiat/django/commit/0b96027f697c173f860be2cef18451a715dbe7f1
But I will probably move it to the check framework, because apps are not ready at this point (loading settings). Apps need to be registered in order to get their labels (please correct me if I'm wrong and there is other clean way to do it).
EDIT:
Check framework based version:
https://github.com/kswiat/django/commit/506391bf1295f6fcd31a74a345fa210a224705e7
comment:4 by , 10 years ago
Needs tests: | set |
---|
comment:6 by , 10 years ago
Wouldn't it be better to check this in the loaddata fixture_dirs
method?
comment:7 by , 10 years ago
Patch needs improvement: | set |
---|
comment:8 by , 10 years ago
Cc: | added |
---|
There is new PR with different approach, that checks settings.FIXTURE_DIRS in the loaddata fixture_dirs method. If there are duplicates or default fixture dir of an app, exception is raised.
https://github.com/django/django/pull/3447
Or maybe it should emit a warning instead of raising?
I mistakenly edited comment:6 by claudep. Sorry for that. Is there a problem with trac's permissions?
comment:9 by , 10 years ago
Patch needs improvement: | unset |
---|
comment:10 by , 10 years ago
Needs documentation: | set |
---|---|
Patch needs improvement: | set |
comment:11 by , 10 years ago
Needs documentation: | unset |
---|---|
Patch needs improvement: | unset |
I added release notes for 1.7.2, 1.8 and improved patch.
comment:12 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
In this situation, Django could raise an
ImproperlyConfigured
exception, emit a warning (maybe with a check?), or at least deduplicate the list. Loading the fixture twice doesn't make sense.Regarding your second question, yes, this is the intended behavior.