-
Notifications
You must be signed in to change notification settings - Fork 11
MagiCollection settings in Edit view
deby edited this page May 11, 2020
·
5 revisions
↑ Parent: MagiCollection settings
← Previous: MagiCollection settings in Add view
- Edit views contain the following settings (can be overridden):
Key | Value | Default | Example |
---|---|---|---|
after_template | Name of a template to include after the form | None | "include/afterAddCard" |
allow_delete | Should we show a button to delete the item as well? | False | |
back_to_list_button | Should we display a button to go back to the list view at the end of the form? | True | |
form_class | Form class to edit an item. Can be a method (see below). Can be specified in collection. | AutoForm | |
multipart | Should the HTML form allow multipart (uploaded files)? Can be specified in collection. | False | |
otherbuttons_template | Template path (without .html ) for extra buttons at the end of the form |
None | "include/cardsExtraButtons" |
savem2m | Should we call save_m2m to save the manytomany items after saving this model? | Will automatically check for presence of manytomany fields |
See also: MagiCollection settings in All views.
- Edit views contain the following methods (can be overridden):
Name | Description | Parameters | Return value | Default |
---|---|---|---|---|
get_page_title | See Page titles and descriptions | item=None, type=None, is_translate=False | Translated string | unicode of item |
get_h1_title | See Page titles and descriptions | request, context, item, type=None, is_translate=False | list of dict, dict | See Page titles and descriptions |
check_translate_permissions | Check if the current user has permissions to access the form to edit translations. Should raise PermissionDenied if needed. |
request, context | None | check for translate_items permission |
check_type_permissions | Check if the current user has permissions to edit this specific type of item (See Item types). Should raise PermissionDenied if needed. |
request, context, type=None, item=None | None | None |
allow_cascade_delete_up_to | When a user tries to delete an item, a warning will show up to indicate what will be deleted automatically with it. This limit can prevent users from deleting too many items, even when they confirm the warning. Users are then advised to delete the dependencies manually. See user documentation. Super users are not affected by this limit. | request | integer or None | 10 |
after_save | Function called after the form is saved.
|
request, instance, type=None | instance | Just returns the instance |
before_delete | Function called before the item gets deleted. | request, instance, ajax | None | Nothing |
before_save | Function called before the form is saved.
|
request, instance, type=None | instance | Just returns the instance |
form_class | Form class to edit an item. Doesn't have to be a method (see above). Can be specified in collection. | request, context | A form class | AutoForm |
get_item | How is the item retrieved using the pk (=id) provided in the URL? For example, in the URL /card/edit/12/ , pk will be 12
|
request, pk (in URL) | a dictionary that will be used with the queryset to get a single item | { 'pk': pk } |
redirect_after_delete | Where should the user be redirected after the item has been deleted successfully? | request, item, ajax | URL to redirect to | Redirect to the list view |
redirect_after_edit | Where should the user be redirected after the item has been edited successfully? | request, item, ajax | URL to redirect to | Redirect to the item view of the item that has been edited if the item view is enabled, otherwise to the list view |
See also: MagiCollection methods in All views.
- Edit views provide the following methods (not meant to be overridden):
Name | Description | Parameters | Return value |
---|---|---|---|
has_translate_permissions | Calls check_translate_permissions , catches exceptions and returns True or False |
request, context | True or False |
has_type_permissions | Calls check_type_permissions , catches exceptions and returns True or False |
request, context | True or False |
See also: MagiCollection methods in All views.
ℹ︎ See also: Views
→ Next: Account collection settings
I. Introduction
II. Tutorials
III. References
- Files tree
- Default collections
- Default pages
- Website settings
- MagiCollection settings
- Abstract models
- Abstract collections
- MagiForm settings
- MagiFiltersForm settings
- Single pages settings
IV. Utils
-
MagiModel utils
- MagiModel images and files
- DateTime fields
- BaseAccount model
- Save choices values as integer rather than strings
- Store comma separated values
- Store dictionaries
- Store Markdown texts
- Translate fields values in multiple languages
- Store JSON
- More model field types
- Transform images before saving them
- Check choices at form level instead of model level
- Use an internal cache for foreign keys in models
- Customize views with MagiModel properties
- Events
- Form utils
- Python utils
- Templates utils
- Javascript utils
- Enable and disable existing collections and pages
- Translations
- Page titles and descriptions
- Characters
- Seasons
- Roles and permissions
- Allow your staff team to change configurations
- Custom users preferences and settings
- Background illustrations
- Activities tabs
- Corner popups
VI. More