The first step to using Stoat is defining the templates you want to use for pages.
You define the templates Stoat will use in your Django settings. Here’s a quick example to get you started:
STOAT_TEMPLATES = {
'Default': ['default.html', [
['Heading', 'char'],
['Body', 'ckeditor', { 'required': True }],
['Sidebar Body', 'text'],
['Sidebar Links', 'inline', { 'import': 'sidebar.admin.SidebarLinkInline' }],
]],
'Product': ['pages/product.html', [
['Price', 'int', { 'required': True }],
['Description', 'text'],
['Image', 'img'],
['Salesperson', 'fk', { 'app': 'auth', 'model': 'User' }],
]],
}
STOAT_DEFAULT_TEMPLATE = 'Default'
The STOAT_TEMPLATES setting contains a dictionary mapping template names to template definitions.
Each template definition consists of:
The path is a normal Django template path, like you might use with render_to_response.
Each field is a list containing a name and a field type. The field name is how the field will be labels in the admin and referred to in your templates, and the field type is one of the supported types detailed in the next section.
The option dictionary maps options to values. Some options (such as required) can be used with any kind of field, while others are specific to a certain field type. See the Field Options section for more information on universal options, and the Field Types section for options specific to a single type.
There’s also a STOAT_DEFAULT_TEMPLATE setting that you need to set to the name of the template that should be considered the default.
The following types of fields are available for use.
Note: Stoat actually stores all field data as Text data. The field types only change the form field type used (and validated) in the admin.
A basic Django BooleanField.
A CKEditor field. This requires that django-ckeditor be installed.
Options
A basic Django DecimalField.
A basic Django EmailField.
A basic Django FloatField.
A foreign key to a model. When using this field you must provide both of its options.
Options
A FileBrowseField from django-filebrowser, with the 'Image' type.
An inline field allows you to create models that have a ForeignKey pointing at Stoat pages.
Check out the :doc:`Inlines </inlines>`_ documentation for more information.
A basic Django IntegerField.
The following options can be used for any field.
Ensures that this field is not left blank when editing the page in the admin interface.
Defines help text for individual fields.
Next you’ll want to check out the Admin documentation to learn how to use the admin interface for adding pages (it’s simple), and the Templating documentation to learn how to create Django templates for use with Stoat.