Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#31738 closed Uncategorized (invalid)

invalid exception thrown "django.core.exceptions.ImproperlyConfigured: settings.FIXTURE_DIRS contains duplicates."

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 (last modified by Mariusz Felisiak)

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 (2)

comment:1 by Mariusz Felisiak, 5 years ago

Component: UncategorizedCore (Management commands)
Description: modified (diff)
Easy pickings: unset
Resolution: invalid
Status: newclosed

FIXTURE_DIRS=('piece/core/fixtures') is not a list or tuple it's a string that contains duplicates e.g. 'e'.

Closing per TicketClosingReasons/UseSupportChannels.

comment:2 by Mariusz Felisiak, 5 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top