Models

Database models for djangocms-stories.

Core Models

Post

class Post(*args, **kwargs)

Bases: Model

Represents a blog post or story entry with multilingual content, images, categories, tags, and publication metadata. It is the “grouper model” for PostContent.

This model supports translation, site-specific publishing, image handling, tagging, and flexible URL generation for posts.

author

User who authored the post; optional and protected from deletion while referenced.

date_created

Timestamp when the post grouper was first created. Set automatically.

date_modified

Timestamp automatically updated whenever the post is saved. Set automatically. Does not reflect changes to PostContent instances.

date_published

Start of the publication window; Posts remain invisible before that date. They are visible if the field is empty. When working with django CMS versioning this field is set automatically upon first publication of a PostContent instance. Otherwise, it will need to be set manually.

date_published_end

Optional end of the publication window after which the post is no longer public. Posts are visible if the field is empty or if the date is in the future. Posts stay visible indefinitely if the field is empty. When working with django CMS versioning this field is set automatically when a PostContent instance with a future publication date is published. Otherwise, it will need to be set manually.

Optional date used to feature/sort content independently from publication date.

include_in_rss

Controls whether this post appears in generated RSS feeds.

categories

Categories assigned to the post for navigation, filtering, and URL generation.

main_image

Primary image used in listings, detail views, and social metadata.

main_image_thumbnail

Thumbnail preset to apply when rendering the main image in compact contexts.

main_image_full

Thumbnail preset to apply when rendering the main image at full/detail size.

enable_comments

Enables or disables comments for this specific post.

sites

Restricts visibility to specific Django sites; empty means all configured sites.

app_config

Stories app configuration controlling namespace, URL scheme, and behavior.

tags = <taggit.managers._TaggableManager object>

Free-form tags used for filtering, discovery, and tag-based plugin queries.

related

Manually curated, ordered links to other posts for editorial recommendations.

objects = <djangocms_stories.managers.GenericDateTaggedManager object>
__init__(*args, **kwargs)
featured()
get_content(language=None, show_draft_content=False)
get_admin_content(language=None)
safe_translation_getter(field, default=None, language_code=None, any_language=False, show_draft_content=False)

Fetch a content property, and return a default value when both the translation and fallback language are missing.

When any_language=True is used, the function also looks into other languages to find a suitable value. This feature can be useful for “title” attributes for example, to make sure there is at least something being displayed. Also consider using field = TranslatedField(any_language=True) in the model itself, to make this behavior the default for the given field.

property guid
property date
get_available_languages()
get_absolute_url(language=None)
get_title(language=None)
get_keywords(language=None)

Returns the list of keywords (as python list) :return: list

get_description(language=None)
get_image_full_url()
get_image_width()
get_image_height()
get_author()

Return the author (user) objects

get_author_url()

Return the author URL if available

thumbnail_options()
full_image_options()
get_cache_key(language, prefix)
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

app_config_id
author_id
featuredpostsplugin_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

get_next_by_date_created(*, field=<django.db.models.fields.DateTimeField: date_created>, is_next=True, **kwargs)
get_next_by_date_modified(*, field=<django.db.models.fields.DateTimeField: date_modified>, is_next=True, **kwargs)
get_previous_by_date_created(*, field=<django.db.models.fields.DateTimeField: date_created>, is_next=False, **kwargs)
get_previous_by_date_modified(*, field=<django.db.models.fields.DateTimeField: date_modified>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

main_image_full_id
main_image_id
main_image_thumbnail_id
post_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

postcontent_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

tagged_items

Accessor to the related objects manager on the one-to-many relation created by GenericRelation.

In the example:

class Post(Model):
    comments = GenericRelation(Comment)

post.comments is a ReverseGenericManyToOneDescriptor instance.

PostContent

class PostContent(id, post, language, title, slug, subtitle, abstract, meta_description, meta_keywords, meta_title, post_text)

Bases: PostMetaMixin, ModelMeta, Model

structure_template = 'post_detail.html'
no_structure_template = 'no_post_structure.html'
post

Grouper relation linking this translated content row to its parent post.

language

en, de, fr).

Type:

Language code for this translation variant (for example

title

Main post title shown in lists, detail pages, and metadata fallbacks.

slug

Per-language URL slug; auto-generated from title when left empty.

subtitle

Optional secondary heading displayed beneath or alongside the title.

abstract

Short rich-text summary used in previews, listings, and meta fallbacks.

meta_description

SEO/social description for this language variant of the post.

meta_keywords

Comma-separated keywords used by metadata integrations.

meta_title

Custom page and sharing title; falls back to title when not provided.

post_text

Primary rich-text body content for the translated post if using plugins is disabled.

placeholders

django CMS placeholders container for structured plugin-based content regions.

objects = <djangocms_stories.managers.SiteManager object>
admin_manager = <djangocms_stories.managers.AdminManager object>
property author
property date_published
property date_published_end
property date_modified
property app_config
property categories
media
content
save(*args, **kwargs)

Handle some auto-configuration during save

get_absolute_url(language=None)
get_template()
get_title()
get_keywords()

Returns the list of keywords (as python list) :return: list

get_description()
get_image_full_url()
get_image_width()
get_image_height()
get_tags()

Returns the list of object tags as comma separated list

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

post_id

Category Models

PostCategory

class PostCategory(*args, **kwargs)

Bases: PostMetaMixin, ModelMeta, TranslatableModel

Post category allows to structure content in a hierarchy of categories.

parent

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

date_created

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

date_modified

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

app_config

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

priority

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

main_image

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

main_image_thumbnail

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

main_image_full

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

translations

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

descendants()
get_descendants()
linked_posts

returns all linked posts in the same appconfig namespace

count
count_all_sites
get_absolute_url(lang=None)

Returns the absolute URL for the category overview in the specified language. If the category has a translation in the given language, returns the URL for the category’s detail page using its slug. If the category does not exist in the specified language, falls back to the URL for the latest posts. :param lang: The language code to use for the URL. If not provided, determines the language automatically. :type lang: str, optional

Returns:

The absolute URL for the category or the latest posts, depending on translation availability.

Return type:

str

save(*args, **kwargs)

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

delete(*args, **kwargs)
get_title()
get_description()
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

abstract

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

app_config_id
children

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

get_next_by_date_created(*, field=<django.db.models.fields.DateTimeField: date_created>, is_next=True, **kwargs)
get_next_by_date_modified(*, field=<django.db.models.fields.DateTimeField: date_modified>, is_next=True, **kwargs)
get_previous_by_date_created(*, field=<django.db.models.fields.DateTimeField: date_created>, is_next=False, **kwargs)
get_previous_by_date_modified(*, field=<django.db.models.fields.DateTimeField: date_modified>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

latestpostsplugin_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

main_image_full_id
main_image_id
main_image_thumbnail_id
meta_description

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

name

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

parent_id
posts

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

slug

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

Plugin Models

BasePostPlugin

class BasePostPlugin(*args, **kwargs)

Bases: CMSPlugin

app_config

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

current_site

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

template_folder

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class Meta

Bases: object

abstract = False
app_config_id
cmsplugin_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

cmsplugin_ptr_id
get_template_folder_display(*, field=<django.db.models.fields.CharField: template_folder>)
__init__(*args, **kwargs)
optimize(qs)

Apply select_related / prefetch_related to optimize the view queries :param qs: queryset to optimize :return: optimized queryset

post_content_queryset(request=None, selected_posts=None)

LatestPostsPlugin

class LatestPostsPlugin(id, placeholder, parent, position, language, plugin_type, creation_date, changed_date, cmsplugin_ptr, app_config, current_site, template_folder, latest_posts)

Bases: BasePostPlugin

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

app_config

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

app_config_id
cmsplugin_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

cmsplugin_ptr_id
current_site

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_template_folder_display(*, field=<django.db.models.fields.CharField: template_folder>)
tagged_items

Accessor to the related objects manager on the one-to-many relation created by GenericRelation.

In the example:

class Post(Model):
    comments = GenericRelation(Comment)

post.comments is a ReverseGenericManyToOneDescriptor instance.

template_folder

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

latest_posts

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

tags = <taggit.managers._TaggableManager object>
categories

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

copy_relations(old_instance)

Handle copying of any relations attached to this plugin. Custom plugins have to do this themselves.

See also: Handling-Relations, post_copy().

Parameters:

old_instance (CMSPlugin instance) – Source plugin instance

get_post_contents(request)

AuthorEntriesPlugin

class AuthorEntriesPlugin(id, placeholder, parent, position, language, plugin_type, creation_date, changed_date, cmsplugin_ptr, app_config, current_site, template_folder, latest_posts)

Bases: BasePostPlugin

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

app_config

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

app_config_id
cmsplugin_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

cmsplugin_ptr_id
current_site

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_template_folder_display(*, field=<django.db.models.fields.CharField: template_folder>)
template_folder

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

authors

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

latest_posts

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

copy_relations(oldinstance)

Handle copying of any relations attached to this plugin. Custom plugins have to do this themselves.

See also: Handling-Relations, post_copy().

Parameters:

old_instance (CMSPlugin instance) – Source plugin instance

get_post_contents(request)
get_authors(request)

FeaturedPostsPlugin

class FeaturedPostsPlugin(id, placeholder, parent, position, language, plugin_type, creation_date, changed_date, cmsplugin_ptr, app_config, current_site, template_folder)

Bases: BasePostPlugin

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

app_config

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

app_config_id
cmsplugin_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

cmsplugin_ptr_id
current_site

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_template_folder_display(*, field=<django.db.models.fields.CharField: template_folder>)
template_folder

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

posts
copy_relations(oldinstance)

Handle copying of any relations attached to this plugin. Custom plugins have to do this themselves.

See also: Handling-Relations, post_copy().

Parameters:

old_instance (CMSPlugin instance) – Source plugin instance

get_posts(request)

GenericBlogPlugin

class GenericBlogPlugin(id, placeholder, parent, position, language, plugin_type, creation_date, changed_date, cmsplugin_ptr, app_config, current_site, template_folder)

Bases: BasePostPlugin

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

app_config

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

app_config_id
cmsplugin_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

cmsplugin_ptr_id
current_site

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_template_folder_display(*, field=<django.db.models.fields.CharField: template_folder>)
template_folder

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.