Admin

Django admin integration for stories management.

Admin Classes

PostAdmin

class PostAdmin(model, admin_site)[source]

Bases: FrontendEditableAdminMixin, ModelAppHookConfig, GrouperModelAdmin

app_config_initial_fields = ('app_config', 'content__language')
extra_grouping_fields: tuple[str, ...] = ('language',)

Indicates additional grouping fields such as "language" for example. Additional grouping fields create tabs in the change form and a dropdown menu in the change list view.

Note

All fields serving as extra grouping fields must be part of the admin’s fieldsets setting for GrouperModelAdmin to work properly. In the change form the fields will be invisible.

inlines = []
list_display = ('title', 'author', 'app_config')
search_fields = ('content__title', 'content__subtitle', 'author__last_name', 'author__first_name')
readonly_fields = ('date_created', 'date_modified')
date_hierarchy = 'date_published'
autocomplete_fields = ['author']
frontend_editable_fields = ('title', 'abstract', 'post_text')
enhance_exclude = ('main_image', 'tags')
actions = ['enable_comments', 'disable_comments']
title(obj)[source]
get_form(request, obj=None, **kwargs)[source]

Adds the language from the request to the form class

can_change_content(request, content_obj)[source]

Returns True if user can change content_obj

enable_comments(request, queryset)[source]

Bulk action to enable comments for selected posts. queryset must not be empty (ensured by django CMS).

disable_comments(request, queryset)[source]

Bulk action to disable comments for selected posts. queryset must not be empty (ensured by django CMS).

get_list_filter(request)[source]

Return a sequence containing the fields to be displayed as filters in the right sidebar of the changelist page.

lookup_allowed(lookup, *args)[source]
get_urls()[source]

Customize the modeladmin urls

has_restricted_sites(request)[source]

Whether the current user has permission on one site only

Parameters:

request – current request

Returns:

boolean: user has permission on only one site

get_restricted_sites(request)[source]

The sites on which the user has permission on.

To return the permissions, the method check for the get_sites method on the user instance (e.g.: return request.user.get_sites()) which must return the queryset of enabled sites. If the attribute does not exists, the user is considered enabled for all the websites.

Parameters:

request – current request

Returns:

boolean or a queryset of available sites

get_fieldsets(request, obj=None)[source]

Customize the fieldsets according to the app settings

Parameters:
  • request – request

  • obj – post

Returns:

fieldsets configuration

save_model(request, obj, form, change)[source]

Save/create both grouper and content object

get_queryset(request)[source]

Annotates content fields with the name “content__{field_name}” to the grouper queryset if for all content fields that appear in the

Given the HttpRequest, the parent ModelForm instance, the list of inline formsets and a boolean value based on whether the parent is being added or changed, save the related objects to the database. Note that at this point save_form() and save_model() have already been called.

property media

PostContentAdmin

class PostContentAdmin(model, admin_site)[source]

Bases: FrontendEditableAdminMixin, ModelAdmin

frontend_editable_fields = ['post_text', 'title', 'subtitle']
change_view(request, object_id, form_url='', extra_context=None)[source]

Redirect to grouper change view to allow for FrontendEditing of Post Content fields

get_model_perms(request)[source]

Return empty perms dict thus hiding the model from admin index.

property media

CategoryAdmin

class CategoryAdmin(model, admin_site)[source]

Bases: FrontendEditableAdminMixin, TranslatableAdmin

form

alias of CategoryAdminForm

list_display = ['name', 'parent', 'app_config', 'all_languages_column']
fieldsets = ((None, {'fields': ('parent', 'app_config', 'name', 'slug', 'meta_description')}), ('Info', {'classes': ('collapse',), 'fields': ('abstract',)}), ('Image', {'classes': ('collapse',), 'fields': ('main_image', ('main_image_thumbnail', 'main_image_full'))}))
autocomplete_fields = ['parent']
search_fields = ['translationas__name', 'meta_description']
class Media[source]

Bases: object

css = {'all': ('djangocms_stories/css/djangocms_stories_admin.css',)}
property media

StoriesConfigAdmin

Inline Classes

PostContentInline

RelatedPostInline

Admin Mixins

TranslatableAdminMixin

AppConfigFilterMixin

Admin Filters

CategoryFilter

PublishedFilter

AuthorFilter