Opened 4 years ago

Last modified 4 years ago

#31738 closed Uncategorized

invalid exception thrown "django.core.exceptions.ImproperlyConfigured: settings.FIXTURE_DIRS contains duplicates." — at Initial Version

Reported by: timharsch Owned by: nobody
Component: Core (Management commands) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

loaddata.py incorrectly throws an ImproperlyConfigured exception when FIXTURE_DIRS is a list of one. See:
https://github.com/django/django/blame/798835112d81b852efaae0e067af389c733cd1b3/django/core/management/commands/loaddata.py#L296

I changed this code to:
286 print(fixture_dirs)
287 print(len(fixture_dirs))
288 print(len(set(fixture_dirs)))
289 if len(fixture_dirs) != len(set(fixture_dirs)):
290 raise ImproperlyConfigured("settings.FIXTURE_DIRS contains duplicates.")

and set my FIXTURE_DIRS like so:
FIXTURE_DIRS=('piece/core/fixtures','piece/core/fixtures2')

when I run loaddata I see:
('piece/core/fixtures', 'piece/core/fixtures2')
2
2
Installed 6 object(s) from 2 fixture(s)

so far so good. Now set it like so:
FIXTURE_DIRS=('piece/core/fixtures)

I run it and get:

piece/core/fixtures
19
12
Traceback (most recent call last):

File "manage.py", line 16, in <module>

execute_from_command_line(sys.argv)

File "/Users/harsch/.pyenv/versions/p38/lib/python3.8/site-packages/django/core/management/init.py", line 401, in execute_from_command_line

utility.execute()

File "/Users/harsch/.pyenv/versions/p38/lib/python3.8/site-packages/django/core/management/init.py", line 395, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)

File "/Users/harsch/.pyenv/versions/p38/lib/python3.8/site-packages/django/core/management/base.py", line 328, in run_from_argv

self.execute(*args, cmd_options)

File "/Users/harsch/.pyenv/versions/p38/lib/python3.8/site-packages/django/core/management/base.py", line 369, in execute

output = self.handle(*args, options)

File "/Users/harsch/.pyenv/versions/p38/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 72, in handle

self.loaddata(fixture_labels)

File "/Users/harsch/.pyenv/versions/p38/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 106, in loaddata

if self.find_fixtures(fixture_label):

File "/Users/harsch/.pyenv/versions/p38/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 235, in find_fixtures

fixture_dirs = self.fixture_dirs

File "/Users/harsch/.pyenv/versions/p38/lib/python3.8/site-packages/django/utils/functional.py", line 48, in get

res = instance.dict[self.name] = self.func(instance)

File "/Users/harsch/.pyenv/versions/p38/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 290, in fixture_dirs

raise ImproperlyConfigured("settings.FIXTURE_DIRS contains duplicates.")

django.core.exceptions.ImproperlyConfigured: settings.FIXTURE_DIRS contains duplicates.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top