Dmitri Lebedev committed bf78a37

rearranged the code, incompatible changes to parameters

Comments (0)

Files changed (3)


     if len(bits) != 3:
         raise TemplateSyntaxError("%s tag requires exactly two arguments: object and the field to edit" % bits[0])
-    return EditableNode(nodelist, parser.compile_filter(bits[1]), bits[2])
+    return EditableNode(nodelist, *map(parser.compile_filter, bits[1:]))
 class EditableNode(Node):
     def render(self, context):
         inner_content = self.nodelist.render(context)
         obj = self.obj.resolve(context)
+        field = self.field.resolve(context)
         class_name = obj.__class__.__name__
         app_label = obj._meta.app_label
         if not context['user'].has_perm('%s.can_edit' % obj.__class__.__name__, obj):
             return inner_content
         return loader.render_to_string(templates_list('inline-editable.html', obj), {
-            'class': class_name,
-            'label': app_label,
-            'id':,
-            'field': self.field,
+            'obj': obj,
+            'field': field,
             'inner': inner_content,
+def editable_id(obj, field_name):
+    class_name = obj.__class__.__name__
+    app_label = obj._meta.app_label
+    return '%s.%s.%s.%s' % (app_label, class_name,, field_name)


 from django.db.models import get_model
 from django.http import HttpResponse, Http404
 from django.shortcuts import render_to_response, get_object_or_404
+from django.template import RequestContext
 from django_inline import templates_list
     def decorated(request):
         # the id can be in get, post or put method
         # this has to be de-hard-coded
-        id = any(getattr(request, method, {}).get('id') for method in ('GET', 'POST', 'PUT'))
+        for method in ('GET', 'POST', 'PUT'):
+            id = getattr(request, method, {}).get('id')
+            if id:
+                break
             app_label, class_name, pk, field_name = id.split('.')
         except ValueError:  # if the number of items in the string is wrong
     return render_to_response(templates_list('inline-form.html', obj), {
         'form': Form(initial={'id': id, 'data': getattr(obj, field_name)}),
-    })
+        'obj': obj,
+        'field': field_name,
+    }, context_instance=RequestContext(request))
+    install_requires=(
+        'Django',
+    ),
     package_dir={'': 'example'},
     packages=find_packages('example', exclude=('*.pyc', '*~'))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.