Skip to content

MagiCollection settings in All views

deby edited this page Nov 24, 2021 · 4 revisions

↑ Parent: MagiCollection settings

  • All views share the following settings (can be overriden):
Key Value Default Example
enbabled Whether the view should be available or not. True
ajax Is the view available in ajax? (allow to get just the page content without HTML boilerplate and navigation bar) True
ajax_callback String name of a Javascript function to call when the view loaded. None 'loadCards'
js_files List of javascript files to include, all files are in static/js except if it starts with bower/ [] ['cards.js, 'bower/marked/lib/marked']
shortcut_urls
  • ListView/AddView: List of URLs
  • AddView with types: List or (url, type) or list of URLs
  • ItemView/EditView: List of (url, pk) or list of URLs
[] [('me', 1)]
multipart Are Add/Edit forms multipart (ie contain files upload)? Can be specified in collection. multipart in collection True
authentication_required Permissions: only when the user is authenticated
  • ListView/ItemView: False
  • AddView/EditView: True
logout_required Permissions: only when the user is NOT authenticated False
staff_required Permissions: only when the user is authenticated AND part of the staff team False
owner_only Permissions: only for ItemView/EditView, only when the authenticated user is the owner of the item
  • ItemView: False
  • EditView: True
disable_on_high_traffic False When HIGH_TRAFFIC is set to True in local settings, the view will be disabled and a message will be shown to users.
  • All views provide the following properties (not meant to be overriden):
Key Value Example
collection The MagiCollection object associated with this view CardCollection()
  • All views share the following methods (can be overriden):
Name Description Parameters Return value Default
get_global_context Function called to pre-fill the context before the view loads (even before checking for permissions) request dictionary GET_GLOBAL_CONTEXT specified in settings for the website.
share_image Image displayed when sharing this view on social media (Facebook, Twitter, etc). Full URL. Can be specified in collection. context, item=None String URL share_image in MagiCollection
extra_context Allows you to add extra context, typically for your templates. Called after most of the logic for the view has been executed already. Example context dictionary Just returns the context
get_queryset Queryset used to retrieve the item(s). Can be specified in collection. queryset, parameters, request Django queryset get_queryset in MagiCollection
check_permissions See Roles and permissions
check_owner_permissions See Roles and permissions
  • All views provide the following methods (not meant to be overriden):
Name Description Parameters Return value
has_permissions See Roles and permissions
get_page_title Get the title of the page None localized string

ℹ︎ See also: Views

→ Next: List view

I. Introduction

II. Tutorials

  1. Collections
    1. MagiModel
    2. MagiCollection
    3. MagiForm
    4. MagiFiltersForm
    5. MagiFields
  2. Single pages
  3. Configuring the navbar

III. References

IV. Utils

V. Advanced tutorials

VI. More

Clone this wiki locally