First off, I am new to both django and python.
-- I am extending an existing app. We have several admin.py files
They all look like this:
#!/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)
Everything has been working.
I added my classes
#!/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)
This also works fine locally, but when we deploy it, it blows up on the import:
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
I am running 2.7.10 locally. The failing machine is running 2.7.6. I'm not sure how to switch my env around, but why would other admin.py files import guardian.admin correctly?
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/171b4b5e-e6b6-4695-889d-c0ed35ae0ebe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment