Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed #19164 -- Diffsettings commands fails to force load settings #461

Closed
wants to merge 1 commit into from

2 participants

@mariocesar

Related to ticket #18545, it was added an argument to the setup method of the LazySettings object.

The diffsettings command call settings._setup() to force load all settings and then show to the user.

$ python manage.py diffsettings --traceback
Traceback (most recent call last):
  File "/home/mariocesar/Proyectos/Crowddeals/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 222, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/mariocesar/Proyectos/Crowddeals/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 252, in execute
    output = self.handle(*args, **options)
  File "/home/mariocesar/Proyectos/Crowddeals/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 382, in handle
    return self.handle_noargs(**options)
  File "/home/mariocesar/Proyectos/Crowddeals/env/local/lib/python2.7/site-packages/django/core/management/commands/diffsettings.py", line 19, in handle_noargs
    settings._setup()
TypeError: _setup() takes exactly 2 arguments (1 given)

I fix this by making the name argument optional

class LazySettings(LazyObject):
    """
    A lazy proxy for either global Django settings or a custom settings object.
    The user can manually configure settings prior to using them. Otherwise,
    Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE.
    """
    def _setup(self, name=None):

...
@carljm
Owner

Thanks for the pull request! I committed a version of this as 3541a10

@carljm carljm closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  django/conf/__init__.py
@@ -25,7 +25,7 @@ class LazySettings(LazyObject):
The user can manually configure settings prior to using them. Otherwise,
Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE.
"""
- def _setup(self, name):
+ def _setup(self, name=None):
"""
Load the settings module pointed to by the environment variable. This
is used the first time we need any settings at all, if the user has not
View
0  tests/regressiontests/bug19164/__init__.py
No changes.
View
1  tests/regressiontests/bug19164/models.py
@@ -0,0 +1 @@
+
View
11 tests/regressiontests/bug19164/test_settings.py
@@ -0,0 +1,11 @@
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3'
+ },
+}
+
+SECRET_KEY = "secret_key"
+
+PASSWORD_HASHERS = (
+ 'django.contrib.auth.hashers.MD5PasswordHasher',
+)
View
16 tests/regressiontests/bug19164/tests.py
@@ -0,0 +1,16 @@
+import sys, os
+from django.utils.unittest import TestCase
+from django.utils.six import StringIO
+from django.core.management import call_command
+
+class Bug19164Test(TestCase):
+ """
+ Test for bug #19164 -
+ """
+ def test_bug_19164(self):
+ """Just make sure running the command don't raise the error"""
+ out = StringIO()
+ try:
+ call_command('diffsettings', stdout=out)
+ except TypeError, ex:
+ self.assertNotEqual(str(ex), '_setup() takes exactly 2 arguments (1 given)')
Something went wrong with that request. Please try again.