Models

Database models for djangocms-stories.

Core Models

Post

class Post(*args, **kwargs)[source]

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

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.

date_published

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

date_published_end

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

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

include_in_rss

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

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.

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.

enable_comments

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

sites

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.

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.

tags = <taggit.managers._TaggableManager object>
related
objects = <djangocms_stories.managers.GenericDateTaggedManager object>
__init__(*args, **kwargs)[source]
featured()[source]
get_content(language=None, show_draft_content=False)[source]
safe_translation_getter(field, default=None, language_code=None, any_language=False, show_draft_content=False)[source]

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()[source]
get_absolute_url(language=None)[source]
get_title(language=None)[source]
get_keywords(language=None)[source]

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

get_description(language=None)[source]
get_image_full_url()[source]
get_image_width()[source]
get_image_height()[source]
get_author()[source]

Return the author (user) objects

get_author_url()[source]

Return the author URL if available

thumbnail_options()[source]
full_image_options()[source]
get_cache_key(language, prefix)[source]
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)[source]

Bases: PostMetaMixin, ModelMeta, Model

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

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.

language

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

title

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

slug

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

subtitle

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

abstract

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

meta_description

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

meta_keywords

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

meta_title

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

post_text

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

placeholders

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.

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)[source]

Handle some auto-configuration during save

get_absolute_url(language=None)[source]
get_template()[source]
get_title()[source]
get_keywords()[source]

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

get_description()[source]
get_image_full_url()[source]
get_image_width()[source]
get_image_height()[source]
get_tags()[source]

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)[source]

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()[source]
get_descendants()[source]
linked_posts

returns all linked posts in the same appconfig namespace

count
count_all_sites
get_absolute_url(lang=None)[source]

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)[source]

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)[source]
get_title()[source]
get_description()[source]
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.

Configuration Models

StoriesConfig

class StoriesConfig(*args, **kwargs)[source]

Bases: TranslatableModel

Class representing a stories configuration.

This class inherits from TranslatableModel.

type

Represents the type of the stories config.

Type:

models.CharField

namespace

Represents the namespace of the instance.

Type:

models.CharField

translations

Represents the translated fields of the stories config.

Type:

TranslatedFields

default_image_full

Represents the default size of full images.

Type:

models.ForeignKey

default_image_thumbnail

Represents the default size of thumbnail images.

Type:

models.ForeignKey

url_patterns

Represents the structure of permalinks.

Type:

models.CharField

use_placeholder

Represents whether to use placeholder and plugins for article body.

Type:

models.BooleanField

use_abstract

Represents whether to use abstract field.

Type:

models.BooleanField

Represents whether to enable related posts.

Type:

models.SmallIntegerField

urlconf

Represents the URL config.

Type:

models.CharField

set_author

Represents whether to set author by default.

Type:

models.BooleanField

paginate_by

Represents the number of articles per page for pagination.

Type:

models.SmallIntegerField

template_prefix

Represents the alternative directory to load the stories templates from.

Type:

models.CharField

menu_structure

Represents the menu structure.

Type:

models.CharField

menu_empty_categories

Represents whether to show empty categories in menu.

Type:

models.BooleanField

sitemap_changefreq

Represents the changefreq attribute for sitemap items.

Type:

models.CharField

sitemap_priority

Represents the priority attribute for sitemap items.

Type:

models.DecimalField

object_type

Represents the object type.

Type:

models.CharField

og_type

Represents the Facebook type.

Type:

models.CharField

og_app_id

Represents the Facebook application ID.

Type:

models.CharField

og_profile_id

Represents the Facebook profile ID.

Type:

models.CharField

og_publisher

Represents the Facebook page URL.

Type:

models.CharField

og_author_url

Represents the Facebook author URL.

Type:

models.CharField

og_author

Represents the Facebook author.

Type:

models.CharField

twitter_type

Represents the Twitter type field.

Type:

models.CharField

twitter_site

Represents the Twitter site handle.

Type:

models.CharField

twitter_author

Represents the Twitter author handle.

Type:

models.CharField

gplus_type

Represents the Schema.org object type.

Type:

models.CharField

gplus_author

Represents the Schema.org author name abstract field.

Type:

models.CharField

type

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

namespace

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

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.

default_image_full

Default size of full images

default_image_thumbnail

Default size of thumbnail images

url_patterns

Structure of permalinks (get_absolute_url); see AVAILABLE_PERMALINK_STYLES

use_placeholder

USE_PLACEHOLDER)

Type:

Use placeholder and plugins for article body (default

use_abstract

USE_ABSTRACT)

Type:

Use abstract field (default

use_related

USE_RELATED)

Type:

Enable related posts (default

set_author

AUTHOR_DEFAULT)

Type:

Set author by default (default

paginate_by

PAGINATION)

Type:

When paginating list views, how many articles per page? (default

template_prefix

“”)

Type:

Alternative directory to load the stories templates from (default

menu_structure

MENU_TYPE_COMPLETE, see MENU_TYPES)

Type:

Menu structure (default

menu_empty_categories

MENU_EMPTY_CATEGORIES)

Type:

Show empty categories in menu (default

sitemap_changefreq

SITEMAP_CHANGEFREQ_DEFAULT, see: SITEMAP_CHANGEFREQ)

Type:

Sitemap changefreq (default

sitemap_priority

SITEMAP_PRIORITY_DEFAULT)

Type:

Sitemap priority (default

object_type

TYPE, see TYPES)

Type:

Object type (default

og_type

FB_TYPE, see FB_TYPES)

Type:

Facebook type (default

og_app_id

FB_PROFILE_ID)

Type:

Facebook application ID (default

og_profile_id

FB_PROFILE_ID)

Type:

Facebook profile ID (default

og_publisher

FB_PUBLISHER)

Type:

Facebook page URL (default

og_author_url

FB_AUTHOR_URL)

Type:

Facebook author URL (default

og_author

FB_AUTHOR)

Type:

Facebook author (default

twitter_type

TWITTER_TYPE)

Type:

Twitter type field (default

twitter_site

TWITTER_SITE)

Type:

Twitter site handle (default

twitter_author

TWITTER_AUTHOR)

Type:

Twitter author handle (default

gplus_type

SCHEMAORG_TYPE)

Type:

Schema.org object type (default

gplus_author

SCHEMAORG_AUTHOR)

Type:

Schema.org author name abstract field (default

send_knock_create

Send notifications on post update. Requires channels integration

send_knock_update

Send notifications on post update. Requires channels integration

get_app_title()[source]
save(*args, **kwargs)[source]

Delete menu cache upon safe

delete(*args, **kwargs)[source]

Delete menu cache upon delete

property schemaorg_type

Compatibility shim to fetch data from legacy gplus_type field.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

app_title

Descriptor for translated attributes.

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

authorentriesplugin_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.

default_image_full_id
default_image_thumbnail_id
featuredpostsplugin_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.

genericblogplugin_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.

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 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.

object_name

Descriptor for translated attributes.

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

post_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.

postcategory_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.

Model Managers

PostManager

PostContentManager

CategoryManager