Wednesday, March 2, 2011

Grapelli, Django, and objects_name

KeyError exception that says "objects_name" is not defined.

http://groups.google.com/group/django-grappelli/browse_thread/thread/160e85c07557d280

The issue has already been reported here:

http://code.google.com/p/django-grappelli/issues/detail?id=342

The problem appears to be that the objects_name template context variable has been changed in the latest Django dev distribution (but apparently not in Django 1.3 beta that's currently on the site). You have to copy the templates/admin/delete_selected_confirmation.html from the django-grappelli directory into your own templates/admin directory, and then change objects_name variable to object_name. This patch appears to fix the issue:
Index: templates/admin/delete_selected_confirmation.html
===================================================================
--- templates/admin/delete_selected_confirmation.html (revision 1401)
+++ templates/admin/delete_selected_confirmation.html (working copy)
@@ -18,7 +18,7 @@
     <div class="container-grid delete-confirmation">
         {% if perms_lacking %}
             <div class="module">
-                <h2>{% blocktrans %}Deleting the {{ objects_name }} would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:{% endblocktrans %}</h2>
+                <h2>{% blocktrans %}Deleting the {% endblocktrans %}{{ object_name }}{% blocktrans %} would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:{% endblocktrans %}</h2>
                 <div class="row">
                     <ul class="rte">
                         {% for obj in perms_lacking %}
@@ -29,7 +29,7 @@
             </div>
         {% else %}
             <div class="module">
-                <h2>{% blocktrans %}Are you sure you want to delete the selected {{ objects_name }} objects? All of the following objects and their related items will be deleted:{% endblocktrans %}</h2>
+                <h2>{% blocktrans %}Are you sure you want to delete the selected {% endblocktrans %}{{ object_name }}{% blocktrans %} objects? All of the following objects and their related items will be deleted:{% endblocktrans %}</h2>
                 {% for deleteable_object in deletable_objects %}
                     <div class="row">
                         <ul class="rte">{{ deleteable_object|unordered_list }}</ul>

No comments:

Post a Comment