[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

/usr/bin/django-admin in python-django



While I am happy with the majority of this package, not sure about this wrapper. It was designed to prevent conflicts between python-django and python3-django.

As an example:

(wheezy)root@aquitard:~# /usr/bin/django-admin dumpdata --settings=karaage.tests.settings       
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/django/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 261, in fetch_command
    commands = get_commands()
  File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 107, in get_commands
    apps = settings.INSTALLED_APPS
  File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 54, in __getattr__
    self._setup(name)
  File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 49, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 132, in __init__
    % (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'karaage.tests.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named tests.settings

The problem is that the django-admin wrapper chose the python3 version, but karaage.tests.settings is only available in Python2, even though I have python3-django installed.

However, anything I do here will mean making changes from upstream.

I guess I could also try to parse the --settings or DJANGO_SETTINGS_MODULE, try to determine automatically if the Python3 version exists. However I think this could get very messy very quickly and probably won't work in all cases.


This is significant for me, as I have postinst scripts that do the following:

django-admin collectstatic --settings=kgadmin.conf.settings --noinput

Have changed that now to:

python2.7 /usr/lib/python2.7/dist-packages/django/bin/django-admin.py \
            collectstatic --settings=kgadmin.conf.settings --noinput

Can change it for new packages, not for old packages though. I don't see any good solution for this though.

Hopefully nobody else does this :-)
--
Brian May <brian@microcomaustralia.com.au>

Reply to: