First off, I am new to both django and python.
-- I am working on an existing project that is using django-guardian 1.3.2
There are existing admin.py files, which load just fine.
#!/usr/bin/env python
# coding: utf-8
from guardian.admin import GuardedModelAdmin
from django.contrib import admin
from devices import models
class SomeModelAdmin(GuardedModelAdmin):
pass
admin.site.register(models.SomeModel, SomeModelAdmin)
I added mine, and this also works (on my machine).
#!/usr/bin/env python
# coding: utf-8
from guardian.admin import GuardedModelAdmin
from django.contrib import admin
from common import models
class MyModel1Admin(GuardedModelAdmin):
pass
admin.site.register(models.Model, MyModel1Admin)
class MyModel2Admin(GuardedModelAdmin):
pass
admin.site.register(models.Model2, MyModel2Admin)
We deployed the app, and now it fails to start with the following exception:
Traceback (most recent call last):
File "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
self.load_middleware()
File "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware
mw_instance = mw_class()
File "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/middleware/locale.py", line 24, in __init__
for url_pattern in get_resolver(None).url_patterns:
File "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/urlresolvers.py", line 365, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/core/urlresolvers.py", line 360, in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
File "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "./sites/zpanel/urls.py", line 19, in <module>
admin.autodiscover()
File "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 29, in autodiscover
import_module('%s.admin' % app)
File "/usr/local/share/.virtualenvs/my_app/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "./common/admin.py", line 3, in <module>
from guardian.admin import GuardedModelAdmin
ImportError: No module named admin
The server is running python 2.7.6, and I am using 2.7.10. I wouldn't think this is an issue since other admin.py files import from guardina.admin just fine.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3b338659-3ba3-4e66-8a19-6831efec7de8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment