Skip to content

Commit 0437b3b

Browse files
committed
Documentation update
1 parent 4de0d6c commit 0437b3b

File tree

1 file changed

+20
-35
lines changed

1 file changed

+20
-35
lines changed

docs/extending_cms/frontend_models.rst

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ up the your model's template.
2121
Set up the template
2222
===================
2323

24-
Add ``show_editable_model``:
24+
Add ``show_editable_model``::
2525

2626
{% load placeholder_tags %}
2727

@@ -35,15 +35,15 @@ See `templatetag reference <show_editable_model_reference>`_ for description of
3535
Selected fields edit
3636
********************
3737

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.
4040

4141
Set up the admin
4242
================
4343

4444
First you need to properly setup your admin class by adding the
4545
``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::
4747

4848
from cms.admin.placeholderadmin import FrontendEditableAdmin
4949
from django.contrib import admin
@@ -56,33 +56,13 @@ a tuple of fields editable from the frontend admin
5656
Set up the template
5757
===================
5858

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::
6161

6262
{% load placeholder_tags %}
6363

6464
{% 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>
8666
{% endblock content %}
8767

8868

@@ -94,9 +74,6 @@ Special attributes
9474
The ``attribute`` argument of the templatetag is not required to be a field of
9575
the model, you can also use a property or a method as a target.
9676

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-
10077
.. _custom-views:
10178

10279
************
@@ -110,10 +87,18 @@ template.
11087

11188
Custom views can be specified by either passing the ``view_url`` attribute
11289
(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
11592
a complete URL.
11693

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+
117102
.. _show_editable_model_reference:
118103

119104
*********************
@@ -135,13 +120,13 @@ Arguments:
135120
* ``attribute``: the name of the attribute you want to show in the template; it
136121
can be a context variable name; it's possible to target field, property or
137122
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;
140123
* ``edit_fields`` (optional): a comma separated list of fields editable in the
141124
popup editor;
142-
* ``view_method`` (optional): a method name that will return a URL to a view;
143125
* ``language`` (optional): the admin language tab to be linked. Useful only for
144126
`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;
145130

146131

147132
.. _django-hvad: https://github.com/kristianoellegaard/django-hvad

0 commit comments

Comments
 (0)