@@ -29,7 +29,7 @@ Add ``show_editable_model``::
29
29
<h1>{% show_editable_model instance "some_attribute" %}</h1>
30
30
{% endblock content %}
31
31
32
- See `templatetag reference <show_editable_model_reference >`_ for description of arguments.
32
+ See `templatetag reference <show_editable_model_reference >`_ for arguments documentation .
33
33
34
34
********************
35
35
Selected fields edit
@@ -80,25 +80,43 @@ the model, you can also use a property or a method as a target.
80
80
Custom views
81
81
************
82
82
83
- You can link any field to a custom view (not necessarily an admin view); in any
84
- case your view does not need to obey any specific interface, other than
85
- possibly check to ``_popup `` query string parameter to select a popup-enabled
86
- template.
83
+ You can link any field to a custom view (not necessarily an admin view) to handle
84
+ model-specific editing workflow.
87
85
88
- Custom views can be specified by either passing the ``view_url `` attribute
89
- (which will be passed to the ``reverse `` function with the instance ``pk `` and
90
- ``language `` arguments) or by using the ``view_method `` to pass a method
91
- (or property) of the model instance; this property / method must return
92
- a complete URL.
86
+ The custom view can be passed either as a named url (``view_url ``) or as name
87
+ (``view_method ``) of a method (or property) on the instance being edited.
88
+ In case you provide ``view_method `` it will be called whenever the templatetag is
89
+ evaluated with ``request `` as first parameter.
93
90
94
- Example::
91
+ The custom view does not need to obey any specific interface, but it will get
92
+ ``edit_fields `` value as a ``GET `` parameter.
93
+
94
+ See `templatetag reference <show_editable_model_reference >`_ for arguments documentation.
95
+
96
+ Example ``view_url ``::
95
97
96
98
{% load placeholder_tags %}
97
99
98
100
{% block content %}
99
101
<h1>{% show_editable_model instance "some_attribute" "some_field,other_field" "" "admin:exampleapp_example1_some_view" %}</h1>
100
102
{% endblock content %}
101
103
104
+
105
+ Example ``view_method ``::
106
+
107
+ class MyModel(models.Model):
108
+ char = models.CharField(max_length=10)
109
+
110
+ def some_method(self, request):
111
+ return "/some/url"
112
+
113
+
114
+ {% load placeholder_tags %}
115
+
116
+ {% block content %}
117
+ <h1>{% show_editable_model instance "some_attribute" "some_field,other_field" "" "some_method" %}</h1>
118
+ {% endblock content %}
119
+
102
120
.. _show_editable_model_reference :
103
121
104
122
*********************
@@ -125,8 +143,9 @@ Arguments:
125
143
* ``language `` (optional): the admin language tab to be linked. Useful only for
126
144
`django-hvad `_ enabled models.
127
145
* ``view_url `` (optional): the name of a url that will be reversed using the
128
- instance ``pk `` and the ``attribute `` (or `` edit_field ``) as arguments;
146
+ instance ``pk `` and the ``language `` as arguments;
129
147
* ``view_method `` (optional): a method name that will return a URL to a view;
148
+ the method must accept ``request `` as first parameter.
130
149
131
150
132
- .. _django-hvad : https://github.com/kristianoellegaard/django-hvad
151
+ .. _django-hvad : https://github.com/kristianoellegaard/django-hvad
0 commit comments