Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autodiscovering does not work #10

Closed
gagarski opened this issue Sep 15, 2014 · 2 comments
Closed

Autodiscovering does not work #10

gagarski opened this issue Sep 15, 2014 · 2 comments

Comments

@gagarski
Copy link

Hello!
I am using django 1.7 and trying to enable autodiscovering of rules.py files as it shown in the README file:

INSTALLED_APPS = (
    # ...
    'rules',
    'rules.apps.AutodiscoverRulesConfig',
)

But I am getting the following error:

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3.4/site-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/usr/lib/python3.4/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/lib/python3.4/site-packages/django/apps/registry.py", line 89, in populate
    "duplicates: %s" % app_config.label)
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: rules

When I am disabling rules application:

INSTALLED_APPS = (
    # ...
    #'rules',
    'rules.apps.AutodiscoverRulesConfig',
)

I am getting another error (when I am trying to load any page):

ImportError at /
No module named 'rules.apps.AutodiscoverRulesConfig'; 'rules.apps' is not a package
Request Method: GET
Request URL:    http://localhost:8000/
Django Version: 1.7
Exception Type: ImportError
Exception Value:    
No module named 'rules.apps.AutodiscoverRulesConfig'; 'rules.apps' is not a package
Exception Location: /usr/lib/python3.4/site-packages/authority/__init__.py in autodiscover, line 21
Python Executable:  /usr/bin/python
Python Version: 3.4.1

What is the correct way of using autodiscover?

@dfunckt
Copy link
Owner

dfunckt commented Sep 15, 2014

You don't need both 'rules' and 'rules.apps.AutodiscoverRules' in INSTALLED_APPS. In fact you mustn't -- that's what the first error tells you (django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: rules)

I see the exception location is in "django-authority", can you please remove it from INSTALLED_APPS and see if the error goes away?

Either way, please paste the whole traceback.

@gagarski
Copy link
Author

I hadn't authority app installed, but I forgot to remove its import from project's urls.py.
Yes, it seems to be a problem with django-authority, which does not work with django 1.7. Thanks a lot.

Traceback, as you have asked for.

Environment:


Request Method: GET
Request URL: http://localhost:8000/

Django Version: 1.7
Python Version: 3.4.1
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'rules.apps.AutodiscoverRulesConfig',
 'polyauth',
 'main',
 'polylog')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "/usr/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
  98.                 resolver_match = resolver.resolve(request.path_info)
File "/usr/lib/python3.4/site-packages/django/core/urlresolvers.py" in resolve
  338.             for pattern in self.url_patterns:
File "/usr/lib/python3.4/site-packages/django/core/urlresolvers.py" in url_patterns
  367.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/lib/python3.4/site-packages/django/core/urlresolvers.py" in urlconf_module
  361.             self._urlconf_module = import_module(self.urlconf_name)
File "/usr/lib/python3.4/importlib/__init__.py" in import_module
  109.     return _bootstrap._gcd_import(name[level:], package, level)
File "/home/gagarski/polyana-web/polyana_web/urls.py" in <module>
  5. authority.autodiscover()
File "/usr/lib/python3.4/site-packages/authority/__init__.py" in autodiscover
  21.             __import__(app)

Exception Type: ImportError at /
Exception Value: No module named 'rules.apps.AutodiscoverRulesConfig'; 'rules.apps' is not a package

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants