Tuesday, October 15, 2013

ImportError: cannot import name actions

I have recently been testing the 1.6b4 tag with a new app we are writing, using apache and wsgi. However, I could not get rid of the following issue happening on every request:

...
[Tue Oct 15 12:50:36 2013] [error] [client 127.0.0.1]   File "/home/rok/apps/django-trunk/django/contrib/gis/admin/__init__.py", line 2, in <module>
[Tue Oct 15 12:50:36 2013] [error] [client 127.0.0.1]     from django.contrib.admin import autodiscover, site, AdminSite, ModelAdmin, StackedInline, TabularInline, HORIZONTAL, VERTICAL
[Tue Oct 15 12:50:36 2013] [error] [client 127.0.0.1]   File "/home/rok/apps/django-trunk/django/contrib/admin/__init__.py", line 6, in <module>
[Tue Oct 15 12:50:36 2013] [error] [client 127.0.0.1]     from django.contrib.admin.sites import AdminSite, site
[Tue Oct 15 12:50:36 2013] [error] [client 127.0.0.1]   File "/home/rok/apps/django-trunk/django/contrib/admin/sites.py", line 3, in <module>
[Tue Oct 15 12:50:36 2013] [error] [client 127.0.0.1]     from django.contrib.admin import ModelAdmin, actions
[Tue Oct 15 12:50:36 2013] [error] [client 127.0.0.1] ImportError: cannot import name actions

by doing the following change, I could get rid of what looked like a circular import issue:
--- a/django/contrib/admin/sites.py
+++ b/django/contrib/admin/sites.py
@@ -1,6 +1,7 @@
 from functools import update_wrapper
 from django.http import Http404, HttpResponseRedirect
-from django.contrib.admin import ModelAdmin, actions
+from django.contrib.admin import ModelAdmin
+from django.contrib.admin.actions import delete_selected
 from django.contrib.admin.forms import AdminAuthenticationForm
 from django.contrib.auth import REDIRECT_FIELD_NAME
 from django.contrib.contenttypes import views as contenttype_views
@@ -46,7 +47,7 @@ class AdminSite(object):
         self._registry = {}  # model_class class -> admin_class instance
         self.name = name
         self.app_name = app_name
-        self._actions = {'delete_selected': actions.delete_selected}
+        self._actions = {'delete_selected': delete_selected}
         self._global_actions = self._actions.copy()
 
     def register(self, model_or_iterable, admin_class=None, **options):

Switching to 1.5.4 resolves the issue as well (even though the sites.py code is the same). What is more, this did not occur in the development environment when using the runserver run.

Any clue?

--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/636730c0-6d2a-40d8-8837-8b9d73e40f24%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate