Fix whitespace errors in docs

Trimmed trailing whitespace, convert tabs to 4 spaces, add preference
for spaces to `.editorconfig`.
This commit is contained in:
Tim Heap 2016-11-28 12:40:15 +11:00 committed by Matt Westcott
parent 254e675634
commit 6ba34636cb
29 changed files with 167 additions and 167 deletions

View file

@ -5,7 +5,7 @@ end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{css,js,json,py,yml}]
[*.{css,js,json,py,yml,rst}]
indent_style = space
[*.{js,py}]

View file

@ -102,7 +102,7 @@ To begin, import the ``Format`` class, ``register_image_format`` function, and o
The label used in the chooser form when inserting the image into the :class:`~wagtail.wagtailcore.fields.RichTextField`.
``classnames``
The string to assign to the ``class`` attribute of the generated ``<img>`` tag.
The string to assign to the ``class`` attribute of the generated ``<img>`` tag.
.. note::
Any class names you provide must have CSS rules matching them written separately, as part of the front end CSS code. Specifying a ``classnames`` value of ``left`` will only ensure that class is output in the generated markup, it won't cause the image to align itself left.

View file

@ -78,7 +78,7 @@ Here's an example of how this could be implemented (with English as the main lan
This returns the language code for this page.
"""
# Look through ancestors of this page for its language homepage
# The language homepage is located at depth 3
# The language homepage is located at depth 3
language_homepage = self.get_ancestors(inclusive=True).get(depth=3)
# The slug of language homepages should always be set to the language code

View file

@ -4,7 +4,7 @@ Animated GIF support
Pillow, Wagtail's default image library, doesn't support animated
GIFs.
To get animated GIF support, you will have to
To get animated GIF support, you will have to
`install Wand <http://docs.wand-py.org/en/0.4.2/guide/install.html>`_.
Wand is a binding to ImageMagick so make sure that has been installed as well.

View file

@ -17,15 +17,15 @@ We recommend `Redis <http://redis.io/>`_ as a fast, persistent cache. Install Re
.. code-block:: python
CACHES = {
'default': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': '127.0.0.1:6379',
'OPTIONS': {
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
}
}
}
CACHES = {
'default': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': '127.0.0.1:6379',
'OPTIONS': {
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
}
}
}
Search
@ -74,12 +74,12 @@ The overhead from reading and compiling templates can add up. In some cases a si
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'OPTIONS': {
'loaders': [
('django.template.loaders.cached.Loader', [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
]),
],
'loaders': [
('django.template.loaders.cached.Loader', [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
]),
],
},
}]

View file

@ -87,5 +87,5 @@ The attribute ``password_required_template`` can be defined on a page model to u
class VideoPage(Page):
...
password_required_template = 'video/password_required.html'

View file

@ -67,8 +67,8 @@ If a new function has been introduced by Django that you think would be very use
pass
Tests
~~~~~
~~~~~
Wagtail has a suite of tests, which we are committed to improving and expanding. See :ref:`testing`.
Wagtail has a suite of tests, which we are committed to improving and expanding. See :ref:`testing`.
We run continuous integration at `travis-ci.org/torchbox/wagtail <https://travis-ci.org/torchbox/wagtail>`_ to ensure that no commits or pull requests introduce test failures. If your contributions add functionality to Wagtail, please include the additional tests to cover it; if your contributions alter existing functionality, please update the relevant tests accordingly.

View file

@ -16,11 +16,11 @@ You can sort this listing either via Name or Username.
Clicking on a user's name will open their profile details. From here you can then edit that users details.
.. Note::
It is possible to change user's passwords in this interface, but it is worth encouraging your users to use the 'Forgotten password' link on the login screen instead. This should save you some time!
It is possible to change user's passwords in this interface, but it is worth encouraging your users to use the 'Forgotten password' link on the login screen instead. This should save you some time!
Click the 'Roles' tab to edit the level of access your users have. By default there are three roles:
+--------------+--------------+-----------------+-----------------+
+--------------+--------------+-----------------+-----------------+
| Role | Create drafts| Publish content | Access Settings |
+==============+==============+=================+=================+
| Editor | Yes | No | No |

View file

@ -14,7 +14,7 @@ Documents such as PDFs can be managed from the Documents interface, available in
* When editing a document you can replace the file associated with that document record. This means you can update documents without having to update the pages on which they are placed. Changing the file will change it on all pages that use the document.
* Add or remove tags using the Tags field.
* Save or delete documents using the buttons at the bottom of the interface.
* Save or delete documents using the buttons at the bottom of the interface.
.. Warning::
Deleted documents cannot be recovered.
.. Warning::
Deleted documents cannot be recovered.

View file

@ -5,20 +5,20 @@ If you want to edit, add or remove images from the CMS outside of the individual
.. image:: ../../_static/images/screen31_images_page.png
* Clicking an image will allow you to edit the data associated with it. This includes the Alt text, the photographers credit, the medium of the subject matter and much more.
* Clicking an image will allow you to edit the data associated with it. This includes the Alt text, the photographers credit, the medium of the subject matter and much more.
.. Warning::
Changing the alt text here will alter it for all occurrences of the image in carousels, but not in inline images, where the alt text can be set separately.
.. Warning::
Changing the alt text here will alter it for all occurrences of the image in carousels, but not in inline images, where the alt text can be set separately.
.. image:: ../../_static/images/screen32_image_edit_page.png
Changing the image
__________________
* When editing an image you can replace the file associated with that image record. This means you can update images without having to update the pages on which they are placed.
* When editing an image you can replace the file associated with that image record. This means you can update images without having to update the pages on which they are placed.
.. Warning::
Changing the file will change it on all pages that use the image.
Changing the file will change it on all pages that use the image.
Focal point
___________

View file

@ -20,7 +20,7 @@ The Snippets menu
* Click on an individual snippet to edit, or click 'Add ...' in the top right to add a new snippet
.. Warning::
Editing a snippet will change it on all of the pages on which it has been used. In the top-right of the Snippet edit screen you will see a label saying how many times the snippet has been used. Clicking this label will display a listing of all of these pages.
Editing a snippet will change it on all of the pages on which it has been used. In the top-right of the Snippet edit screen you will see a label saying how many times the snippet has been used. Clicking this label will display a listing of all of these pages.
.. image:: ../../_static/images/screen34_snippet_used_times.png
@ -35,4 +35,4 @@ If you are editing a page, and you find yourself in need of a new snippet, do no
* You should now see your new snippet, even though you didn't leave the edit page.
.. Note::
Even though this is possible, it is worth saving your page as a draft as often as possible, to avoid your changes being lost by navigating away from the edit page accidentally.
Even though this is possible, it is worth saving your page as a draft as often as possible, to avoid your changes being lost by navigating away from the edit page accidentally.

View file

@ -20,7 +20,7 @@ You can return to the Dashboard at any time by clicking the Wagtail logo in the
- Clicking the name of a page will take you to the Edit page interface for this page.
- Clicking approve or reject will either change the page status to live or return the page to draft status. An email will be sent to the creator of the page giving the result of moderation either way.
- The *Parent* column tells you what the parent page of the page awaiting moderation is called. Clicking the parent page name will take you to its Edit page.
- The *Your most recent edits* table displays the five pages that you most recently edited.
- The date column displays the date that you edited the page. Hover your mouse over the date for a more exact time/date.
- The status column displays the current status of the page. A page will have one of three statuses:

View file

@ -6,7 +6,7 @@ _____________________
This examples in this document are based on `Torchbox.com <https://torchbox.com>`_. However, the instructions are general enough as to be applicable to any Wagtail site.
For the purposes of this documentation we will be using the URL, **www.example.com**, to represent the root (homepage) of your website.
For the purposes of this documentation we will be using the URL, **www.example.com**, to represent the root (homepage) of your website.
Logging in
__________

View file

@ -29,7 +29,7 @@ Basic text fields have no formatting options. How these display will be determin
Rich text fields
================
Most of the time though, you need formatting options to create beautiful looking pages. So some fields, like the fields in the 'Paragraph block' shown in the screenshot, have many of the options you would expect from a word processor. These are referred to as rich text fields.
Most of the time though, you need formatting options to create beautiful looking pages. So some fields, like the fields in the 'Paragraph block' shown in the screenshot, have many of the options you would expect from a word processor. These are referred to as rich text fields.
So, when you click into one of these fields, you will be presented with a set of tools which allow you to format and style your text. These tools also allow you to insert links, images, videos clips and links to documents.
@ -84,4 +84,4 @@ Reordering and deleting content in StreamField
* Click the rubbish bin on the far right to delete a field
.. Warning::
Once a StreamField field is deleted it cannot be retrieved if the page has not been saved. Save your pages regularly so that if you accidentally delete a field you can reload the page to undo your latest edit.
Once a StreamField field is deleted it cannot be retrieved if the page has not been saved. Save your pages regularly so that if you accidentally delete a field you can reload the page to undo your latest edit.

View file

@ -61,4 +61,4 @@ The alignments available are described below:
* **Half-width left/right aligned:** Inserts the image at half the width of the text area. If inserted in a block of text the text will wrap around the image. If two half-width images are inserted together they will display next to each other.
.. Note::
The display of images aligned in this way is dependent on your implementation of Wagtail, so you may get slightly different results.
The display of images aligned in this way is dependent on your implementation of Wagtail, so you may get slightly different results.

View file

@ -6,10 +6,10 @@ Inserting videos into body content
As well as inserting videos into a carousel, Wagtail's rich text fields allow you to add videos into the body of a page by clicking the *Add video* button in the toolbar.
.. image:: ../../_static/images/screen20_insert_video_form.png
.. image:: ../../_static/images/screen20_insert_video_form.png
* Copy and paste the web address for the video (either YouTube or Vimeo) into the URL field and click Insert.
.. image:: ../../_static/images/screen21_video_in_editor.png
.. image:: ../../_static/images/screen21_video_in_editor.png
* A placeholder with the name of the video and a screenshot will be inserted into the text area. Clicking the X in the top corner will remove the video.

View file

@ -13,4 +13,4 @@ The second, *Promote*, is where you can set all the 'metadata' (data about data!
.. image:: ../../_static/images/screen26.5_promote_tab.png
.. Note::
You may see more fields than this in your promote tab. These are just the default fields, but you are free to add other fields to this section as necessary.
You may see more fields than this in your promote tab. These are just the default fields, but you are free to add other fields to this section as necessary.

View file

@ -30,7 +30,7 @@ You can add more fields to the pages endpoint by setting an attribute called ``a
.. code-block:: python
class BlogPage(Page):
class BlogPage(Page):
posted_by = models.CharField()
posted_at = models.DateTimeField()
content = RichTextField()
@ -48,7 +48,7 @@ This list also supports child relations (which will be nested inside the returne
api_fields = ['link']
class BlogPage(Page):
class BlogPage(Page):
posted_by = models.CharField()
posted_at = models.DateTimeField()
content = RichTextField()

View file

@ -581,26 +581,26 @@ This is what a typical response from a ``GET`` request to this listing would loo
{
"meta": {
"total_count": 3
},
},
"images": [
{
"id": 4,
"id": 4,
"meta": {
"type": "wagtailimages.Image",
"detail_url": "http://api.example.com/api/v1/images/4/"
},
"title": "Wagtail by Mark Harkin"
},
},
{
"id": 5,
"id": 5,
"meta": {
"type": "wagtailimages.Image",
"detail_url": "http://api.example.com/api/v1/images/5/"
},
"title": "James Joyce"
},
},
{
"id": 6,
"id": 6,
"meta": {
"type": "wagtailimages.Image",
"detail_url": "http://api.example.com/api/v1/images/6/"
@ -631,36 +631,36 @@ By default, this will allow you to add the ``width`` and ``height`` fields to yo
{
"meta": {
"total_count": 3
},
},
"images": [
{
"id": 4,
"id": 4,
"meta": {
"type": "wagtailimages.Image",
"detail_url": "http://api.example.com/api/v1/images/4/"
},
"title": "Wagtail by Mark Harkin",
"width": 640,
"title": "Wagtail by Mark Harkin",
"width": 640,
"height": 427
},
},
{
"id": 5,
"id": 5,
"meta": {
"type": "wagtailimages.Image",
"detail_url": "http://api.example.com/api/v1/images/5/"
},
"title": "James Joyce",
"width": 500,
"title": "James Joyce",
"width": 500,
"height": 392
},
},
{
"id": 6,
"id": 6,
"meta": {
"type": "wagtailimages.Image",
"detail_url": "http://api.example.com/api/v1/images/6/"
},
"title": "David Mitchell",
"width": 360,
"title": "David Mitchell",
"width": 360,
"height": 282
}
]
@ -682,10 +682,10 @@ Exact matches on field values can be done by using a query parameter with the sa
{
"meta": {
"total_count": 3
},
},
"images": [
{
"id": 5,
"id": 5,
"meta": {
"type": "wagtailimages.Image",
"detail_url": "http://api.example.com/api/v1/images/5/"
@ -711,33 +711,33 @@ The images endpoint also accepts the ``order`` parameter which should be set to
{
"meta": {
"total_count": 3
},
},
"images": [
{
"id": 6,
"id": 6,
"meta": {
"type": "wagtailimages.Image",
"detail_url": "http://api.example.com/api/v1/images/6/"
},
"title": "David Mitchell",
"title": "David Mitchell",
"width": 360
},
{
"id": 5,
"id": 5,
"meta": {
"type": "wagtailimages.Image",
"detail_url": "http://api.example.com/api/v1/images/5/"
},
"title": "James Joyce",
"title": "James Joyce",
"width": 500
},
{
"id": 4,
"id": 4,
"meta": {
"type": "wagtailimages.Image",
"detail_url": "http://api.example.com/api/v1/images/4/"
},
"title": "Wagtail by Mark Harkin",
"title": "Wagtail by Mark Harkin",
"width": 640
}
]
@ -762,13 +762,13 @@ Pagination is done using two query parameters called ``limit`` and ``offset``. `
},
"images": [
{
"id": 5,
"id": 5,
"meta": {
"type": "wagtailimages.Image",
"detail_url": "http://api.example.com/api/v1/images/5/"
},
"title": "James Joyce",
"width": 500,
"title": "James Joyce",
"width": 500,
"height": 392
}
]
@ -796,13 +796,13 @@ To perform a full-text search, set the ``search`` parameter to the query string
},
"pages": [
{
"id": 5,
"id": 5,
"meta": {
"type": "wagtailimages.Image",
"detail_url": "http://api.example.com/api/v1/images/5/"
},
"title": "James Joyce",
"width": 500,
"title": "James Joyce",
"width": 500,
"height": 392
}
]
@ -826,13 +826,13 @@ This view gives you access to all of the details for a particular image.
Content-Type: application/json
{
"id": 5,
"id": 5,
"meta": {
"type": "wagtailimages.Image",
"detail_url": "http://api.example.com/api/v1/images/5/"
},
"title": "James Joyce",
"width": 500,
"title": "James Joyce",
"width": 500,
"height": 392
}
@ -862,11 +862,11 @@ This view gives you access to all of the details for a particular document.
Content-Type: application/json
{
"id": 1,
"id": 1,
"meta": {
"type": "wagtaildocs.Document",
"detail_url": "http://api.example.com/api/v1/documents/1/",
"download_url": "http://api.example.com/documents/1/usage.md"
},
},
"title": "Wagtail API usage"
}

View file

@ -1,7 +1,7 @@
Contrib modules
===============
Wagtail ships with a variety of extra optional modules.
Wagtail ships with a variety of extra optional modules.
.. toctree::

View file

@ -27,7 +27,7 @@ do, modeladmin offers the following attributes that you can override:
``ModelAdmin.choose_parent_template_name``
------------------------------------------
**Expected value**: The path to a custom template to use for
**Expected value**: The path to a custom template to use for
``ChooseParentView``
See the following part of the docs to find out more:
@ -39,7 +39,7 @@ See the following part of the docs to find out more:
``ModelAdmin.choose_parent_view_class``
------------------------------------------
**Expected value**: A custom ``view`` class to replace
**Expected value**: A custom ``view`` class to replace
``modeladmin.views.ChooseParentView``
See the following part of the docs to find out more:

View file

@ -3,7 +3,7 @@ Customising ``CreateView``, ``EditView`` and ``DeleteView``
===========================================================
**NOTE:** ``modeladmin`` only provides 'create', 'edit' and 'delete'
functionality for non page type models (i.e. models that do not extend
functionality for non page type models (i.e. models that do not extend
``wagtailcore.models.Page``). If your model is a 'page type' model, customising
any of the following will not have any effect:
@ -27,7 +27,7 @@ model class.
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
address = models.TextField()
panels = [
MultiFieldPanel([
FieldRowPanel([
@ -45,7 +45,7 @@ Or alternatively:
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
address = models.TextField()
custom_panels = [
MultiFieldPanel([
FieldRowPanel([
@ -99,7 +99,7 @@ See the following part of the docs to find out more:
``ModelAdmin.create_view_class``
-----------------------------------
**Expected value**: A custom ``view`` class to replace
**Expected value**: A custom ``view`` class to replace
``modeladmin.views.CreateView``
See the following part of the docs to find out more:
@ -122,7 +122,7 @@ See the following part of the docs to find out more:
``ModelAdmin.edit_view_class``
-----------------------------------
**Expected value**: A custom ``view`` class to replace
**Expected value**: A custom ``view`` class to replace
``modeladmin.views.EditView``
See the following part of the docs to find out more:
@ -145,7 +145,7 @@ See the following part of the docs to find out more:
``ModelAdmin.delete_view_class``
-----------------------------------
**Expected value**: A custom ``view`` class to replace
**Expected value**: A custom ``view`` class to replace
``modeladmin.views.DeleteView``
See the following part of the docs to find out more:

View file

@ -25,18 +25,18 @@ on the ``ModelAdmin`` class itself.
Default value: ``('__str__',)``
Set ``list_display`` to control which fields are displayed in the IndexView
Set ``list_display`` to control which fields are displayed in the IndexView
for your model.
Example
```
list_display = ('first_name', 'last_name')
list_display = ('first_name', 'last_name')
```
You have three possible values that can be used in list_display:
- A field of the model. For example:
- A field of the model. For example:
.. code-block:: python
@ -173,9 +173,9 @@ A few special cases to note about ``list_display``:
By default, the ability to sort results by an item in ``list_display`` is
only offered when it's a field that has an actual database value (because
only offered when it's a field that has an actual database value (because
sorting is done at the database level). However, if the output of the
method is representative of a database field, you can indicate this fact by
method is representative of a database field, you can indicate this fact by
setting the ``admin_order_field`` attribute on that method, like so:
.. code-block:: python
@ -222,8 +222,8 @@ A few special cases to note about ``list_display``:
.. code-block:: python
from django.db import models
class Blog(models.Model):
title = models.CharField(max_length=255)
author = models.ForeignKey(Person, on_delete=models.CASCADE)
@ -235,8 +235,8 @@ A few special cases to note about ``list_display``:
- Elements of ``list_display`` can also be properties. Please note however,
that due to the way properties work in Python, setting
``short_description`` on a property is only possible when using the
that due to the way properties work in Python, setting
``short_description`` on a property is only possible when using the
``property()`` function and **not** with the ``@property`` decorator.
For example:
@ -256,7 +256,7 @@ A few special cases to note about ``list_display``:
full_name = property(full_name_property)
class PersonAdmin(ModelAdmin):
list_display = ('full_name',)
@ -268,7 +268,7 @@ A few special cases to note about ``list_display``:
---------------------------
**Expected value**: A list or tuple, where each item is the name of model field
of type ``BooleanField``, ``CharField``, ``DateField``, ``DateTimeField``,
of type ``BooleanField``, ``CharField``, ``DateField``, ``DateTimeField``,
``IntegerField`` or ``ForeignKey``.
Set ``list_filter`` to activate filters in the right sidebar of the list page
@ -290,7 +290,7 @@ for your model. For example:
of type ``CharField``, ``TextField``, ``RichTextField`` or ``StreamField``.
Set ``search_fields`` to enable a search box at the top of the index page
for your model. You should add names of any fields on the model that should
for your model. You should add names of any fields on the model that should
be searched whenever somebody submits a search query using the search box.
Searching is all handled via Django's queryset API, rather than using Wagtail's
@ -303,7 +303,7 @@ your project is using, and without any additional setup or configuration.
``ModelAdmin.ordering``
---------------------------
**Expected value**: A list or tuple in the same format as a models
**Expected value**: A list or tuple in the same format as a models
[``ordering``](https://docs.djangoproject.com/en/1.9/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display) parameter.
Set ``ordering`` to specify the default ordering of objects when listed by
@ -338,7 +338,7 @@ method of your model's default manager is used. But, if for any reason you
only want a certain sub-set of objects to appear in the IndexView listing,
overriding the ``get_queryset`` method on your ``ModelAdmin`` class can help
you with that. The method takes an ``HttpRequest`` object as a parameter, so
limiting objects by the current logged-in user is possible.
limiting objects by the current logged-in user is possible.
For example:
@ -374,7 +374,7 @@ The `get_extra_attrs_for_row` method allows you to add html attributes to
the opening `<tr>` tag for each result, in addition to the `data-object_pk` and
`class` attributes already added by the `result_row_display` tag.
If you want to add additional CSS classes, simply provide those class names
If you want to add additional CSS classes, simply provide those class names
as a string value using the `class` key, and the `odd`/`even` will be appended
to your custom class names when rendering.
@ -464,7 +464,7 @@ depending on the row's value, you could do something like:
The ``get_extra_attrs_for_field_col`` method allows you to add additional HTML
attributes to any of the columns defined in ``list_display``. Like the
``get_extra_class_names_for_field_col`` method above, this method takes two
parameters:
parameters:
- ``obj``: the object being represented by the current row
- ``field_name``: the item from ``list_display`` being represented by the
@ -539,10 +539,10 @@ kind of interactivity using javascript:
----------------------------------------------------
If you're using ``wagtailimages.Image`` to define an image for each item in
your model, ``ThumbnailMixin`` can help you add thumbnail versions of that
your model, ``ThumbnailMixin`` can help you add thumbnail versions of that
image to each row in ``IndexView``. To use it, simply extend ``ThumbnailMixin``
as well as ``ModelAdmin`` when defining your ``ModelAdmin`` class, and
change a few attributes to change the thumbnail to your liking, like so:
change a few attributes to change the thumbnail to your liking, like so:
.. code-block:: python
@ -555,7 +555,7 @@ change a few attributes to change the thumbnail to your liking, like so:
likes_cat_gifs = models.NullBooleanField()
class PersonAdmin(ThumbnailMixin, ModelAdmin):
# Add 'admin_thumb' to list_display, where you want the thumbnail to appear
list_display = ('admin_thumb', 'name', 'likes_cat_gifs')
@ -569,7 +569,7 @@ change a few attributes to change the thumbnail to your liking, like so:
links to 'wagtailimages.Image'
"""
thumb_image_field_name = 'avatar'
# Optionally override the filter spec used to create each thumb
thumb_image_filter_spec = 'fill-100x100' # this is the default
@ -597,12 +597,12 @@ change a few attributes to change the thumbnail to your liking, like so:
**Expected value**: A string matching one of the items in ``list_display``.
If for any reason you'd like to change which column the action buttons appear
in for each row, you can specify a different column using
in for each row, you can specify a different column using
``list_display_add_buttons`` on your ``ModelAdmin`` class. The value must
match one of the items your class's ``list_display`` attribute. By default,
buttons are added to the first column of each row.
buttons are added to the first column of each row.
See the ``ThumbnailMixin`` example above to see how
See the ``ThumbnailMixin`` example above to see how
``list_display_add_buttons`` can be used.
.. _modeladmin_index_view_extra_css:
@ -646,7 +646,7 @@ See the following part of the docs to find out more:
``ModelAdmin.index_view_class``
---------------------------------------
**Expected value**: A custom ``view`` class to replace
**Expected value**: A custom ``view`` class to replace
``modeladmin.views.IndexView``
See the following part of the docs to find out more:

View file

@ -27,15 +27,15 @@ class:
``ModelAdmin.inspect_view_fields``
------------------------------------------
**Expected value:** A list or tuple, where each item is the name of a field
**Expected value:** A list or tuple, where each item is the name of a field
that you'd like ``InpectView`` to render.
A sensible value will be rendered for most field types.
If a field happens to be a ``ForeignKey`` linking to the
``wagtailimages.Image`` model, a thumbnail of that image will be rendered.
If a field happens to be a ``ForeignKey`` linking to the
``wagtailimages.Image`` model, a thumbnail of that image will be rendered.
If a field happens to be a ``ForeignKey`` linking to the
If a field happens to be a ``ForeignKey`` linking to the
``wagtaildocs.Document`` model, a link to that document will be rendered.
@ -45,7 +45,7 @@ If a field happens to be a ``ForeignKey`` linking to the
``ModelAdmin.inspect_view_fields_exclude``
------------------------------------------
**Expected value:** A list or tuple, where each item is the name of a field
**Expected value:** A list or tuple, where each item is the name of a field
that you'd like to exclude from ``InpectView``
**Note:** If both ``inspect_view_fields`` and ``inspect_view_fields_exclude``
@ -92,7 +92,7 @@ See the following part of the docs to find out more:
``ModelAdmin.inspect_view_class``
---------------------------------------
**Expected value**: A custom ``view`` class to replace
**Expected value**: A custom ``view`` class to replace
``modeladmin.views.InspectView``
See the following part of the docs to find out more:

View file

@ -17,7 +17,7 @@ alter the menu item used to represent your model in Wagtail's admin area.
**Expected value**: A string.
Set this attribute to a string value to override the label used for the menu
Set this attribute to a string value to override the label used for the menu
item that appears in Wagtail's sidebar. If not set, the menu item will use
``verbose_name_plural`` from your model's ``Meta`` data.
@ -36,7 +36,7 @@ sidebar, and will also appear in the header on the list page and other views
for your model. If not set, ``'doc-full-inverse'`` will be used for
page-type models, and ``'snippet'`` for others.
If you're using a ``ModelAdminGroup`` class to group together several
If you're using a ``ModelAdminGroup`` class to group together several
``ModelAdmin`` classes in their own sub-menu, and want to change the menu item
used to represent the group, you should override the ``menu_icon`` attribute on
your ``ModelAdminGroup`` class (``'icon-folder-open-inverse'`` is the default).
@ -67,7 +67,7 @@ greater than that if you wish to keep the explorer menu item at the top.
If you'd like the menu item for your model to appear in Wagtail's 'Settings'
sub-menu instead of at the top level, add ``add_to_setings_menu = True`` to
your ``ModelAdmin`` class.
your ``ModelAdmin`` class.
This will only work for indivdual ``ModelAdmin`` classes registered with their
own ``modeladmin_register`` call. It won't work for members of a

View file

@ -2,7 +2,7 @@
``modeladmin`` customisation primer
===================================
The ``modeladmin`` app is designed to offer you as much flexibility as possible
The ``modeladmin`` app is designed to offer you as much flexibility as possible
in how your model and its objects are represented in Wagtail's CMS. This page
aims to provide you with some background information to help you gain a better
understanding of what the app can do, and to point you in the right direction,
@ -36,13 +36,13 @@ to using to configure Django's add/edit views, simply aren't supported by
Wagtail's version.
'Page type' models need to be treated differently to other models
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
While ``modeladmin``'s listing view and it's supported customisation
options work in exactly the same way for all types of ``Model``, when it
comes to the other management views, the treatment differs depending on
whether your ModelAdmin class is representing a page type model (that
extends ``wagtailcore.models.Page``) or not.
extends ``wagtailcore.models.Page``) or not.
Pages in Wagtail have some unique properties, and require additional views,
interface elements and general treatment in order to be managed
@ -58,13 +58,13 @@ In order to deliver a consistent experience for users, ``modeladmin``
simply redirects users to Wagtail's existing page management views wherever
possible. You should bare this in mind if you ever find yourself wanting to
change what happens when pages of a certain type are added, deleted,
published, or have some other action applied to them. Customising the
published, or have some other action applied to them. Customising the
``CreateView`` or ``EditView`` for your a page type ``Model`` (even it just
to add an additional stylesheet or javascript), simply won't have any
effect, as those views are not used.
If you do find yourself needing to customise the add, edit or other
behaviour for a page type model, you should take a look at the following
behaviour for a page type model, you should take a look at the following
part of the documentation: :ref:`admin_hooks`.
Wagtail's ``ModelAdmin`` class is 'modular'
@ -80,7 +80,7 @@ separate, swappable components.
The theory is: If you want to do something differently, or add some
functionality that ``modeladmin`` doesn't already have, you can create new
classes (or extend the ones provided by ``modeladmin``) and easily
configure your ``ModelAdmin`` class to use them instead of the defaults.
configure your ``ModelAdmin`` class to use them instead of the defaults.
- Learn more about :ref:`modeladmin_overriding_views`
- Learn more about :ref:`modeladmin_overriding_helper_classes`
@ -89,10 +89,10 @@ configure your ``ModelAdmin`` class to use them instead of the defaults.
Changing what appears in the listing
------------------------------------
You should familarise yourself with the attributes and methods supported by
You should familarise yourself with the attributes and methods supported by
the ``ModelAdmin`` class, that allow you to change what is displayed in the
``IndexView``. The following page should give you everything you need to get
going: :doc:`indexview`
going: :doc:`indexview`
.. _modeladmin_adding_css_and_js:
@ -151,7 +151,7 @@ within your project, before resorting to the defaults:
So, to override the template used by ``IndexView`` for example, you'd create a
new ``index.html`` template and put it in one of those locations. For example,
if you wanted to do this for an ``ArticlePage`` model in a ``news`` app, you'd
add your custom template as ``modeladmin/news/article/index.html``.
add your custom template as ``modeladmin/news/article/index.html``.
For reference, ``modeladmin`` looks for templates with the following names for
each view:
@ -211,7 +211,7 @@ For example, if you'd like to create your own view class and use it for the
Or, if you have no need for any of ``IndexView``'s exisiting functionality in
your view, and would rather create your own view from scratch, ``modeladmin``
will support that, too. However, it's highly recommended that you use
will support that, too. However, it's highly recommended that you use
``modeladmin.views.WMABaseView`` as a base for your view. It'll make
integrating with your ``ModelAdmin`` class much easier, and provides a bunch of
useful attributes and methods to get you started.
@ -222,10 +222,10 @@ useful attributes and methods to get you started.
Overriding helper classes
-------------------------
While 'view classes' are responsible for a lot of the work, there are also
While 'view classes' are responsible for a lot of the work, there are also
a number of other tasks that ``modeladmin`` must do regularly, that need to be
handled in a consistent way, and in a number of different places. These tasks
are designated to set of simple classes (in ``modeladmin``, these are termed
are designated to set of simple classes (in ``modeladmin``, these are termed
'helper' classes) and can be found in ``wagtail.contrib.modeladmin.helpers``.
If you ever intend to write and use your own custom views with ``modeladmin``,
@ -243,7 +243,7 @@ There are three types of 'helper class':
generation of buttons for use in a number of places.
The ``ModelAdmin`` class allows you to define and use your own helper classes
by setting values on the following attributes:
by setting values on the following attributes:
.. _modeladmin_url_helper_class:
@ -252,10 +252,10 @@ by setting values on the following attributes:
By default, the ``modeladmin.helpers.PageAdminURLHelper`` class is used when
your model extends ``wagtailcore.models.Page``, otherwise
``modeladmin.helpers.AdminURLHelper`` is used.
``modeladmin.helpers.AdminURLHelper`` is used.
If you find that the above helper classes don't cater for your needs, you can
easily create your own helper class, by sub-classing ``AdminURLHelper`` or
easily create your own helper class, by sub-classing ``AdminURLHelper`` or
``PageAdminURLHelper`` (if your model extend's Wagtail's ``Page`` model), and
making any neccessary additions/overrides.
@ -280,7 +280,7 @@ your ``ModelAdmin`` class to use your custom URLHelper, like so:
modeladmin_register(MyModelAdmin)
Or, if you have a more complicated use case, where simply setting that
Or, if you have a more complicated use case, where simply setting that
attribute isn't possible (due to circular imports, for example) or doesn't
meet your needs, you can override the ``get_url_helper_class`` method, like
so:
@ -289,7 +289,7 @@ so:
class MyModelAdmin(ModelAdmin):
model = MyModel
def get_url_helper_class(self):
if self.some_attribute is True:
return MyURLHelper
@ -303,11 +303,11 @@ so:
By default, the ``modeladmin.helpers.PagePermissionHelper``
class is used when your model extends ``wagtailcore.models.Page``,
otherwise ``wagtail.contrib.modeladmin.helpers.PermissionHelper`` is used.
otherwise ``wagtail.contrib.modeladmin.helpers.PermissionHelper`` is used.
If you find that the above helper classes don't cater for your needs, you can
easily create your own helper class, by sub-classing
``PermissionHelper`` or (if your model extend's Wagtail's ``Page`` model)
``PermissionHelper`` or (if your model extend's Wagtail's ``Page`` model)
``PagePermissionHelper``, and making any neccessary additions/overrides. Once
defined, you set the ``permission_helper_class`` attribute on your
``ModelAdmin`` class to use your custom class instead of the default, like so:
@ -330,15 +330,15 @@ defined, you set the ``permission_helper_class`` attribute on your
modeladmin_register(MyModelAdmin)
Or, if you have a more complicated use case, where simply setting an attribute
isn't possible or doesn't meet your needs, you can override the
Or, if you have a more complicated use case, where simply setting an attribute
isn't possible or doesn't meet your needs, you can override the
``get_permission_helper_class`` method, like so:
.. code-block:: python
class MyModelAdmin(ModelAdmin):
model = MyModel
def get_get_permission_helper_class(self):
if self.some_attribute is True:
return MyPermissionHelper
@ -351,8 +351,8 @@ isn't possible or doesn't meet your needs, you can override the
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
By default, the ``modeladmin.helpers.PageButtonHelper`` class is used when your
model extends ``wagtailcore.models.Page``, otherwise
``modeladmin.helpers.ButtonHelper`` is used.
model extends ``wagtailcore.models.Page``, otherwise
``modeladmin.helpers.ButtonHelper`` is used.
If you wish to add or change buttons for your model's IndexView, you'll need to
create your own button helper class, by sub-classing ``ButtonHelper`` or (if
@ -379,15 +379,15 @@ custom class instead of the default, like so:
modeladmin_register(MyModelAdmin)
Or, if you have a more complicated use case, where simply setting an attribute
isn't possible or doesn't meet your needs, you can override the
Or, if you have a more complicated use case, where simply setting an attribute
isn't possible or doesn't meet your needs, you can override the
``get_button_helper_class`` method, like so:
.. code-block:: python
class MyModelAdmin(ModelAdmin):
model = MyModel
def get_button_helper_class(self):
if self.some_attribute is True:
return MyButtonHelper
@ -411,6 +411,6 @@ Unlike the other two, `self.button_helper` isn't populated right away when
the view is instantiated. In order to show the right buttons for the right
users, ButtonHelper instances need to be 'request aware', so
``self.button_helper`` is only set once the view's ``dispatch()`` method has
run, which takes a ``HttpRequest`` object as an argument, from which the
run, which takes a ``HttpRequest`` object as an argument, from which the
current user can be identified.

View file

@ -94,11 +94,11 @@ First, ``models.py``:
from wagtail.wagtailcore.url_routing import RouteResult
from django.http.response import Http404
from wagtail.wagtailcore.models import Page
...
class Echoer(Page):
def route(self, request, path_components):
if path_components:
# tell Wagtail to call self.serve() with an additional 'path_components' kwarg

View file

@ -62,4 +62,4 @@ Deprecated features
===================
* The ``wagtail.wagtailsearch.indexed`` module has been renamed to ``wagtail.wagtailsearch.index``

View file

@ -28,12 +28,12 @@ Here's an example snippet from the Wagtail demo website:
class Advert(models.Model):
url = models.URLField(null=True, blank=True)
text = models.CharField(max_length=255)
panels = [
FieldPanel('url'),
FieldPanel('text'),
]
def __str__(self):
return self.text
@ -90,9 +90,9 @@ Then, in your own page templates, you can include your snippet template tag with
...
{% block content %}
...
{% adverts %}
{% endblock %}
@ -115,7 +115,7 @@ In the above example, the list of adverts is a fixed list, displayed independent
on_delete=models.SET_NULL,
related_name='+'
)
content_panels = Page.content_panels + [
SnippetChooserPanel('advert'),
# ...
@ -135,28 +135,28 @@ To attach multiple adverts to a page, the ``SnippetChooserPanel`` can be placed
from wagtail.wagtailsnippets.edit_handlers import SnippetChooserPanel
from modelcluster.fields import ParentalKey
...
class BookPageAdvertPlacement(Orderable, models.Model):
page = ParentalKey('demo.BookPage', related_name='advert_placements')
advert = models.ForeignKey('demo.Advert', related_name='+')
class Meta:
verbose_name = "advert placement"
verbose_name_plural = "advert placements"
panels = [
SnippetChooserPanel('advert'),
]
def __str__(self):
return self.page.title + " -> " + self.advert.text
class BookPage(Page):
...
content_panels = Page.content_panels + [
InlinePanel('advert_placements', label="Adverts"),
# ...