djangocms_blog.admin

Admin classes

class djangocms_blog.admin.BlogCategoryAdmin(model, admin_site)
form

alias of djangocms_blog.forms.CategoryAdminForm

get_prepopulated_fields(request, obj=None)

Hook for specifying custom prepopulated fields.

class djangocms_blog.admin.BlogConfigAdmin(model, admin_site)
get_fieldsets(request, obj=None)

Fieldsets configuration

save_model(request, obj, form, change)

Clear menu cache when changing menu structure

class djangocms_blog.admin.PostAdmin(model, admin_site)
_fieldset_extra_fields_position = {'abstract': (0, 1), 'author': (1, 1, 0), 'enable_liveblog': (2, 1, 2), 'post_text': (0, 1), 'related': (1, 1, 0), 'sites': (1, 1, 0)}

Indexes where to append extra fields.

Key: Supported extra / optional field name Value: None / 2 / 3 item tuple. If you want to hide the field in any case set None as dictionary value, otherwise use a tuple containing the index of the the “fields” attribute of the selected fieldset row and an optional third value if the target “fields” has subgroups.

_fieldsets = [(None, {'fields': ['title', 'subtitle', 'slug', 'publish', ['categories', 'app_config']]}), (None, {'fields': [[]]}), ('Info', {'fields': ['tags', ['date_published', 'date_published_end', 'date_featured'], ['enable_comments']], 'classes': ('collapse',)}), ('Images', {'fields': [['main_image', 'main_image_thumbnail', 'main_image_full']], 'classes': ('collapse',)}), ('SEO', {'fields': [['meta_description', 'meta_title', 'meta_keywords']], 'classes': ('collapse',)})]

Default fieldsets structure.

Follow the normal Django fieldsets syntax.

When customizing the structure, check the _fieldset_extra_fields_position to ensure extra fields position matches.

_get_extra_field_position(field)

Return the position in the fieldset where to add the given field.

_patch_fieldsets(fsets, field)

Patch the fieldsets list with additional fields, based on _fieldset_extra_fields_position.

_set_config_defaults(request, form, obj=None)

Cycle through app_config_values and sets the form value according to the options in the current apphook config.

self.app_config_values is a dictionary containing config options as keys, form fields as values:

app_config_values = {
    'apphook_config': 'form_field',
    ...
}
Parameters:
  • request – request object
  • form – model form for the current model
  • obj – current object
Returns:

form with defaults set

disable_comments(request, queryset)

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

disable_liveblog(request, queryset)

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

enable_comments(request, queryset)

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

enable_liveblog(request, queryset)

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

form

alias of djangocms_blog.forms.PostAdminForm

get_fieldsets(request, obj=None)

Customize the fieldsets according to the app settings

Parameters:
  • request – request
  • obj – post
Returns:

fieldsets configuration

get_list_filter(request)

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

get_prepopulated_fields(request, obj=None)

Hook for specifying custom prepopulated fields.

get_queryset(request)

Make sure the current language is selected.

get_restricted_sites(request)

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_urls()

Customize the modeladmin urls

has_restricted_sites(request)

Whether the current user has permission on one site only

Parameters:request – current request
Returns:boolean: user has permission on only one site
make_published(request, queryset)

Bulk action to mark selected posts as published. If the date_published field is empty the current time is saved as date_published. queryset must not be empty (ensured by DjangoCMS).

make_unpublished(request, queryset)

Bulk action to mark selected posts as UNpublished. queryset must not be empty (ensured by DjangoCMS).

publish_post(request, pk)

Admin view to publish a single post

Parameters:
  • request – request
  • pk – primary key of the post to publish
Returns:

Redirect to the post itself (if found) or fallback urls

save_model(request, obj, form, change)

Given a model instance save it to the database.

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.

djangocms_blog.admin.create_post_post_save(model)

A wrapper for creating create_instance function for a specific model.

Admin forms

class djangocms_blog.forms.CategoryAdminForm(*args, **kwargs)
class djangocms_blog.forms.PostAdminForm(*args, **kwargs)