#31738: invalid exception thrown "django.core.exceptions.ImproperlyConfigured:
settings.FIXTURE_DIRS contains duplicates."
-----------------------------------------+------------------------
               Reporter:  timharsch      |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  master
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  1
                  UI/UX:  0              |
-----------------------------------------+------------------------
 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.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31738>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.79f8ab56aef8d805b144d9334e3a63fa%40djangoproject.com.

Reply via email to