@@ -21,7 +21,7 @@ up the your model's template.
21
21
Set up the template
22
22
===================
23
23
24
- Add ``show_editable_model ``:
24
+ Add ``show_editable_model ``::
25
25
26
26
{% load placeholder_tags %}
27
27
@@ -35,15 +35,15 @@ See `templatetag reference <show_editable_model_reference>`_ for description of
35
35
Selected fields edit
36
36
********************
37
37
38
- Frontend editing is also possible for a restricted set of fields, although not
39
- as automatic as the example above.
38
+ Frontend editing is also possible for a set of fields, although not as
39
+ automatic as the example above.
40
40
41
41
Set up the admin
42
42
================
43
43
44
44
First you need to properly setup your admin class by adding the
45
45
``FrontendEditableAdmin `` mixin to the parents of your admin class and declaring
46
- a tuple of fields editable from the frontend admin
46
+ a tuple of fields editable from the frontend admin::
47
47
48
48
from cms.admin.placeholderadmin import FrontendEditableAdmin
49
49
from django.contrib import admin
@@ -56,33 +56,13 @@ a tuple of fields editable from the frontend admin
56
56
Set up the template
57
57
===================
58
58
59
- If you only want to edit the fields to be rendered in the page just add
60
- `` show_editable_model `` to your template :
59
+ Then add a the comma separated list of fields (or just the name of one field)
60
+ to the templatetag: :
61
61
62
62
{% load placeholder_tags %}
63
63
64
64
{% block content %}
65
- <h1>{% show_editable_model instance "some_field" "admin:exampleapp_example1_edit_field" %}</h1>
66
- {% endblock content %}
67
-
68
- The ``admin:exampleapp_example1_edit_field `` string must be changed according
69
- to your application and model names (e.g.: is the application is named ``news ``
70
- and the model is called ``NewsModel `` you'd write the string
71
- ``admin:news_newsmodel_edit_field ``).
72
- The ``edit_field `` is provided by ``FrontendEditableAdmin `` mixin, so you're not
73
- required to write your own admin view (but you can do that, if you want, see
74
- `Custom views <custom-views >`_).
75
-
76
- Edit multiple fields
77
- ====================
78
-
79
- If you want to edit multiple fields at once use the templatetag ``edit_fields ``
80
- attribute:
81
-
82
- {% load placeholder_tags %}
83
-
84
- {% block content %}
85
- <h1>{% show_editable_model instance "some_field" "admin:exampleapp_example1_edit_field" "char_1,char_2" %}</h1>
65
+ <h1>{% show_editable_model instance "some_attribute" "some_field,other_field" %}</h1>
86
66
{% endblock content %}
87
67
88
68
@@ -94,9 +74,6 @@ Special attributes
94
74
The ``attribute `` argument of the templatetag is not required to be a field of
95
75
the model, you can also use a property or a method as a target.
96
76
97
- If you use property or method and link it to single field edit, you **must **
98
- provide the ``edit_fields `` argument to target a specific field to edit.
99
-
100
77
.. _custom-views :
101
78
102
79
************
@@ -110,10 +87,18 @@ template.
110
87
111
88
Custom views can be specified by either passing the ``view_url `` attribute
112
89
(which will be passed to the ``reverse `` function with the instance ``pk `` and
113
- ``attribute_name `` parameters ) or by using the ``view_method `` to pass a
114
- method (or property) of the model instance; this property / method must return
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
115
92
a complete URL.
116
93
94
+ Example::
95
+
96
+ {% load placeholder_tags %}
97
+
98
+ {% block content %}
99
+ <h1>{% show_editable_model instance "some_attribute" "some_field,other_field" "" "admin:exampleapp_example1_some_view" %}</h1>
100
+ {% endblock content %}
101
+
117
102
.. _show_editable_model_reference :
118
103
119
104
*********************
@@ -135,13 +120,13 @@ Arguments:
135
120
* ``attribute ``: the name of the attribute you want to show in the template; it
136
121
can be a context variable name; it's possible to target field, property or
137
122
callable for the specified model;
138
- * ``view_url `` (optional): the name of a url that will be reversed using the
139
- instance ``pk `` and the ``attribute `` (or ``edit_field ``) as arguments;
140
123
* ``edit_fields `` (optional): a comma separated list of fields editable in the
141
124
popup editor;
142
- * ``view_method `` (optional): a method name that will return a URL to a view;
143
125
* ``language `` (optional): the admin language tab to be linked. Useful only for
144
126
`django-hvad `_ enabled models.
127
+ * ``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;
129
+ * ``view_method `` (optional): a method name that will return a URL to a view;
145
130
146
131
147
132
.. _django-hvad : https://github.com/kristianoellegaard/django-hvad
0 commit comments