models Package

models Package

Models for Zinnia

class zinnia.models.Entry(*args, **kwargs)

Bases: zinnia.models.entry.EntryAbstractClass

The final Entry model based on inheritence.

Parameters:
  • id (AutoField) – Id
  • title (CharField) – Title
  • slug (SlugField) – Used to build the entry’s URL.
  • status (IntegerField) – Status
  • start_publication (DateTimeField) – Start date of publication.
  • end_publication (DateTimeField) – End date of publication.
  • creation_date (DateTimeField) – Used to build the entry’s URL.
  • last_update (DateTimeField) – Last update
  • content (TextField) – Content
  • comment_enabled (BooleanField) – Allows comments if checked.
  • pingback_enabled (BooleanField) – Allows pingbacks if checked.
  • trackback_enabled (BooleanField) – Allows trackbacks if checked.
  • comment_count (IntegerField) – Comment count
  • pingback_count (IntegerField) – Pingback count
  • trackback_count (IntegerField) – Trackback count
  • excerpt (TextField) – Optional element.
  • image (ImageField) – Used for illustration.
  • featured (BooleanField) – Featured
  • tags (TagField) – Tags
  • login_required (BooleanField) – Only authenticated users can view the entry.
  • password (CharField) – Protects the entry with a password.
  • content_template (CharField) – Template used to display the entry’s content.
  • detail_template (CharField) – Template used to display the entry’s detail page.
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Entry.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Entry.authors
Entry.categories
Entry.get_absolute_url(*moreargs, **morekwargs)

Builds and returns the entry’s URL based on the slug and the creation date.

Entry.get_content_template_display(*moreargs, **morekwargs)
Entry.get_detail_template_display(*moreargs, **morekwargs)
Entry.get_next_by_creation_date(*moreargs, **morekwargs)
Entry.get_next_by_last_update(*moreargs, **morekwargs)
Entry.get_previous_by_creation_date(*moreargs, **morekwargs)
Entry.get_previous_by_last_update(*moreargs, **morekwargs)
Entry.get_status_display(*moreargs, **morekwargs)
Entry.objects = <django.db.models.manager.Manager object at 0x3889110>
Entry.published = <zinnia.managers.EntryPublishedManager object at 0x3889190>
Entry.related
Entry.sites
class zinnia.models.Author(*args, **kwargs)

Bases: django.contrib.auth.models.User

Proxy model around django.contrib.auth.models.User.

Parameters:
  • id (AutoField) – Id
  • username (CharField) – Required. 30 characters or fewer. Letters, numbers and @/./+/-/_ characters
  • first_name (CharField) – First name
  • last_name (CharField) – Last name
  • email (EmailField) – E-mail address
  • password (CharField) – Password
  • is_staff (BooleanField) – Designates whether the user can log into this admin site.
  • is_active (BooleanField) – Designates whether this user should be treated as active. Unselect this instead of deleting accounts.
  • is_superuser (BooleanField) – Designates that this user has all permissions without explicitly assigning them.
  • last_login (DateTimeField) – Last login
  • date_joined (DateTimeField) – Date joined
exception DoesNotExist

Bases: django.contrib.auth.models.DoesNotExist

exception Author.MultipleObjectsReturned

Bases: django.contrib.auth.models.MultipleObjectsReturned

Author.entries
Author.entries_published()

Returns author’s published entries.

Author.get_absolute_url(*moreargs, **morekwargs)

Builds and returns the author’s URL based on his username.

Author.objects = <django.contrib.auth.models.UserManager object at 0x37f0350>
Author.published = <zinnia.managers.EntryRelatedPublishedManager object at 0x37f0290>
class zinnia.models.Category(*args, **kwargs)

Bases: mptt.models.MPTTModel

Simple model for categorizing entries.

Parameters:
  • id (AutoField) – Id
  • title (CharField) – Title
  • slug (SlugField) – Used to build the category’s URL.
  • description (TextField) – Description
  • parent_id (TreeForeignKey) – Parent category
  • lft (PositiveIntegerField) – Lft
  • rght (PositiveIntegerField) – Rght
  • tree_id (PositiveIntegerField) – Tree id
  • level (PositiveIntegerField) – Level
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Category.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Category.children
Category.entries
Category.entries_published()

Returns category’s published entries.

Category.get_absolute_url(*moreargs, **morekwargs)

Builds and returns the category’s URL based on his tree path.

Category.objects = <mptt.managers.TreeManager object at 0x37f0e50>
Category.parent
Category.published = <zinnia.managers.EntryRelatedPublishedManager object at 0x37f0e90>
Category.tree = <mptt.managers.TreeManager object at 0x37f0e50>
Category.tree_path

Returns category’s tree path by concatening the slug of his ancestors.

author Module

Author model for Zinnia

class zinnia.models.author.Author(*args, **kwargs)

Bases: django.contrib.auth.models.User

Proxy model around django.contrib.auth.models.User.

Parameters:
  • id (AutoField) – Id
  • username (CharField) – Required. 30 characters or fewer. Letters, numbers and @/./+/-/_ characters
  • first_name (CharField) – First name
  • last_name (CharField) – Last name
  • email (EmailField) – E-mail address
  • password (CharField) – Password
  • is_staff (BooleanField) – Designates whether the user can log into this admin site.
  • is_active (BooleanField) – Designates whether this user should be treated as active. Unselect this instead of deleting accounts.
  • is_superuser (BooleanField) – Designates that this user has all permissions without explicitly assigning them.
  • last_login (DateTimeField) – Last login
  • date_joined (DateTimeField) – Date joined
exception DoesNotExist

Bases: django.contrib.auth.models.DoesNotExist

exception Author.MultipleObjectsReturned

Bases: django.contrib.auth.models.MultipleObjectsReturned

Author.entries
Author.entries_published()

Returns author’s published entries.

Author.get_absolute_url(*moreargs, **morekwargs)

Builds and returns the author’s URL based on his username.

Author.objects = <django.contrib.auth.models.UserManager object at 0x37f0350>
Author.published = <zinnia.managers.EntryRelatedPublishedManager object at 0x37f0290>

category Module

Category model for Zinnia

class zinnia.models.category.Category(*args, **kwargs)

Bases: mptt.models.MPTTModel

Simple model for categorizing entries.

Parameters:
  • id (AutoField) – Id
  • title (CharField) – Title
  • slug (SlugField) – Used to build the category’s URL.
  • description (TextField) – Description
  • parent_id (TreeForeignKey) – Parent category
  • lft (PositiveIntegerField) – Lft
  • rght (PositiveIntegerField) – Rght
  • tree_id (PositiveIntegerField) – Tree id
  • level (PositiveIntegerField) – Level
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Category.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Category.children
Category.entries
Category.entries_published()

Returns category’s published entries.

Category.get_absolute_url(*moreargs, **morekwargs)

Builds and returns the category’s URL based on his tree path.

Category.objects = <mptt.managers.TreeManager object at 0x37f0e50>
Category.parent
Category.published = <zinnia.managers.EntryRelatedPublishedManager object at 0x37f0e90>
Category.tree = <mptt.managers.TreeManager object at 0x37f0e50>
Category.tree_path

Returns category’s tree path by concatening the slug of his ancestors.

entry Module

Entry model for Zinnia

class zinnia.models.entry.AuthorsEntry(*args, **kwargs)

Bases: django.db.models.base.Model

Abstract model class to add relationship between the entries and their authors.

class Meta
abstract = False
AuthorsEntry.authors
class zinnia.models.entry.CategoriesEntry(*args, **kwargs)

Bases: django.db.models.base.Model

Abstract model class to categorize the entries.

class Meta
abstract = False
CategoriesEntry.categories
class zinnia.models.entry.ContentEntry(*args, **kwargs)

Bases: django.db.models.base.Model

Abstract content model class providing field and methods to write content inside an entry.

Parameters:content (TextField) – Content
class Meta
abstract = False
ContentEntry.html_content

Returns the “content” field formatted in HTML.

ContentEntry.word_count

Counts the number of words used in the content.

class zinnia.models.entry.ContentTemplateEntry(*args, **kwargs)

Bases: django.db.models.base.Model

Abstract model class to display entry’s content with a custom template.

Parameters:content_template (CharField) – Template used to display the entry’s content.
class Meta
abstract = False
ContentTemplateEntry.get_content_template_display(*moreargs, **morekwargs)
class zinnia.models.entry.CoreEntry(*args, **kwargs)

Bases: django.db.models.base.Model

Abstract core entry model class providing the fields and methods required for publishing content over time.

Parameters:
  • title (CharField) – Title
  • slug (SlugField) – Used to build the entry’s URL.
  • status (IntegerField) – Status
  • start_publication (DateTimeField) – Start date of publication.
  • end_publication (DateTimeField) – End date of publication.
  • creation_date (DateTimeField) – Used to build the entry’s URL.
  • last_update (DateTimeField) – Last update
class Meta

CoreEntry’s meta informations.

abstract = False
app_label = 'zinnia'
get_latest_by = 'creation_date'
ordering = ['-creation_date']
permissions = (('can_view_all', 'Can view all entries'), ('can_change_status', 'Can change status'), ('can_change_author', 'Can change author(s)'))
verbose_name = <django.utils.functional.__proxy__ object at 0x37f9810>
verbose_name_plural = <django.utils.functional.__proxy__ object at 0x37f9850>
CoreEntry.STATUS_CHOICES = ((0, <django.utils.functional.__proxy__ object at 0x37f5c10>), (1, <django.utils.functional.__proxy__ object at 0x37f5c90>), (2, <django.utils.functional.__proxy__ object at 0x37f5cd0>))
CoreEntry.get_absolute_url(*args, **kwargs)

Builds and returns the entry’s URL based on the slug and the creation date.

CoreEntry.get_next_by_creation_date(*moreargs, **morekwargs)
CoreEntry.get_next_by_last_update(*moreargs, **morekwargs)
CoreEntry.get_previous_by_creation_date(*moreargs, **morekwargs)
CoreEntry.get_previous_by_last_update(*moreargs, **morekwargs)
CoreEntry.get_status_display(*moreargs, **morekwargs)
CoreEntry.is_actual

Checks if an entry is within his publication period.

CoreEntry.is_visible

Checks if an entry is visible and published.

CoreEntry.objects = <django.db.models.manager.Manager object at 0x37f9710>
CoreEntry.published = <zinnia.managers.EntryPublishedManager object at 0x37f9750>
CoreEntry.short_url

Returns the entry’s short url.

CoreEntry.sites
class zinnia.models.entry.DetailTemplateEntry(*args, **kwargs)

Bases: django.db.models.base.Model

Abstract model class to display entries with a custom template if needed on the detail page.

Parameters:detail_template (CharField) – Template used to display the entry’s detail page.
class Meta
abstract = False
DetailTemplateEntry.get_detail_template_display(*moreargs, **morekwargs)
class zinnia.models.entry.DiscussionsEntry(*args, **kwargs)

Bases: django.db.models.base.Model

Abstract discussion model class providing the fields and methods to manage the discussions (comments, pingbacks, trackbacks).

Parameters:
  • comment_enabled (BooleanField) – Allows comments if checked.
  • pingback_enabled (BooleanField) – Allows pingbacks if checked.
  • trackback_enabled (BooleanField) – Allows trackbacks if checked.
  • comment_count (IntegerField) – Comment count
  • pingback_count (IntegerField) – Pingback count
  • trackback_count (IntegerField) – Trackback count
class Meta
abstract = False
DiscussionsEntry.comments

Returns a queryset of the published comments.

DiscussionsEntry.comments_are_open

Checks if the comments are open with the AUTO_CLOSE_COMMENTS_AFTER setting.

DiscussionsEntry.discussion_is_still_open(discussion_type, auto_close_after)

Checks if a type of discussion is still open are a certain number of days.

DiscussionsEntry.discussions

Returns a queryset of the published discussions.

DiscussionsEntry.pingbacks

Returns a queryset of the published pingbacks.

DiscussionsEntry.pingbacks_are_open

Checks if the pingbacks are open with the AUTO_CLOSE_PINGBACKS_AFTER setting.

DiscussionsEntry.trackbacks

Return a queryset of the published trackbacks.

DiscussionsEntry.trackbacks_are_open

Checks if the trackbacks are open with the AUTO_CLOSE_TRACKBACKS_AFTER setting.

class zinnia.models.entry.Entry(*args, **kwargs)

Bases: zinnia.models.entry.EntryAbstractClass

The final Entry model based on inheritence.

Parameters:
  • id (AutoField) – Id
  • title (CharField) – Title
  • slug (SlugField) – Used to build the entry’s URL.
  • status (IntegerField) – Status
  • start_publication (DateTimeField) – Start date of publication.
  • end_publication (DateTimeField) – End date of publication.
  • creation_date (DateTimeField) – Used to build the entry’s URL.
  • last_update (DateTimeField) – Last update
  • content (TextField) – Content
  • comment_enabled (BooleanField) – Allows comments if checked.
  • pingback_enabled (BooleanField) – Allows pingbacks if checked.
  • trackback_enabled (BooleanField) – Allows trackbacks if checked.
  • comment_count (IntegerField) – Comment count
  • pingback_count (IntegerField) – Pingback count
  • trackback_count (IntegerField) – Trackback count
  • excerpt (TextField) – Optional element.
  • image (ImageField) – Used for illustration.
  • featured (BooleanField) – Featured
  • tags (TagField) – Tags
  • login_required (BooleanField) – Only authenticated users can view the entry.
  • password (CharField) – Protects the entry with a password.
  • content_template (CharField) – Template used to display the entry’s content.
  • detail_template (CharField) – Template used to display the entry’s detail page.
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Entry.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Entry.authors
Entry.categories
Entry.get_absolute_url(*moreargs, **morekwargs)

Builds and returns the entry’s URL based on the slug and the creation date.

Entry.get_content_template_display(*moreargs, **morekwargs)
Entry.get_detail_template_display(*moreargs, **morekwargs)
Entry.get_next_by_creation_date(*moreargs, **morekwargs)
Entry.get_next_by_last_update(*moreargs, **morekwargs)
Entry.get_previous_by_creation_date(*moreargs, **morekwargs)
Entry.get_previous_by_last_update(*moreargs, **morekwargs)
Entry.get_status_display(*moreargs, **morekwargs)
Entry.objects = <django.db.models.manager.Manager object at 0x3889110>
Entry.published = <zinnia.managers.EntryPublishedManager object at 0x3889190>
Entry.related
Entry.sites
class zinnia.models.entry.EntryAbstractClass(*args, **kwargs)

Bases: zinnia.models.entry.CoreEntry, zinnia.models.entry.ContentEntry, zinnia.models.entry.DiscussionsEntry, zinnia.models.entry.RelatedEntry, zinnia.models.entry.ExcerptEntry, zinnia.models.entry.ImageEntry, zinnia.models.entry.FeaturedEntry, zinnia.models.entry.AuthorsEntry, zinnia.models.entry.CategoriesEntry, zinnia.models.entry.TagsEntry, zinnia.models.entry.LoginRequiredEntry, zinnia.models.entry.PasswordRequiredEntry, zinnia.models.entry.ContentTemplateEntry, zinnia.models.entry.DetailTemplateEntry

Final abstract entry model class assembling all the abstract entry model classes into a single one.

In this manner we can override some fields without reimplemting all the EntryAbstractClass.

Parameters:
  • title (CharField) – Title
  • slug (SlugField) – Used to build the entry’s URL.
  • status (IntegerField) – Status
  • start_publication (DateTimeField) – Start date of publication.
  • end_publication (DateTimeField) – End date of publication.
  • creation_date (DateTimeField) – Used to build the entry’s URL.
  • last_update (DateTimeField) – Last update
  • content (TextField) – Content
  • comment_enabled (BooleanField) – Allows comments if checked.
  • pingback_enabled (BooleanField) – Allows pingbacks if checked.
  • trackback_enabled (BooleanField) – Allows trackbacks if checked.
  • comment_count (IntegerField) – Comment count
  • pingback_count (IntegerField) – Pingback count
  • trackback_count (IntegerField) – Trackback count
  • excerpt (TextField) – Optional element.
  • image (ImageField) – Used for illustration.
  • featured (BooleanField) – Featured
  • tags (TagField) – Tags
  • login_required (BooleanField) – Only authenticated users can view the entry.
  • password (CharField) – Protects the entry with a password.
  • content_template (CharField) – Template used to display the entry’s content.
  • detail_template (CharField) – Template used to display the entry’s detail page.
class Meta

Bases: zinnia.models.entry.Meta

abstract = False
EntryAbstractClass.authors
EntryAbstractClass.categories
EntryAbstractClass.get_content_template_display(*moreargs, **morekwargs)
EntryAbstractClass.get_detail_template_display(*moreargs, **morekwargs)
EntryAbstractClass.get_next_by_creation_date(*moreargs, **morekwargs)
EntryAbstractClass.get_next_by_last_update(*moreargs, **morekwargs)
EntryAbstractClass.get_previous_by_creation_date(*moreargs, **morekwargs)
EntryAbstractClass.get_previous_by_last_update(*moreargs, **morekwargs)
EntryAbstractClass.get_status_display(*moreargs, **morekwargs)
EntryAbstractClass.objects = <django.db.models.manager.Manager object at 0x387a550>
EntryAbstractClass.published = <zinnia.managers.EntryPublishedManager object at 0x387a5d0>
EntryAbstractClass.related
EntryAbstractClass.sites
class zinnia.models.entry.ExcerptEntry(*args, **kwargs)

Bases: django.db.models.base.Model

Abstract model class to add an excerpt to the entries.

Parameters:excerpt (TextField) – Optional element.
class Meta
abstract = False
class zinnia.models.entry.FeaturedEntry(*args, **kwargs)

Bases: django.db.models.base.Model

Abstract model class to mark entries as featured.

Parameters:featured (BooleanField) – Featured
class Meta
abstract = False
class zinnia.models.entry.ImageEntry(*args, **kwargs)

Bases: django.db.models.base.Model

Abstract model class to add an image to the entries.

Parameters:image (ImageField) – Used for illustration.
class Meta
abstract = False
class zinnia.models.entry.LoginRequiredEntry(*args, **kwargs)

Bases: django.db.models.base.Model

Abstract model class to restrcit the display of the entry on authenticated users.

Parameters:login_required (BooleanField) – Only authenticated users can view the entry.
class Meta
abstract = False
class zinnia.models.entry.PasswordRequiredEntry(*args, **kwargs)

Bases: django.db.models.base.Model

Abstract model class to restrict the display of the entry to users knowing the password.

Parameters:password (CharField) – Protects the entry with a password.
class Meta
abstract = False
class zinnia.models.entry.RelatedEntry(*args, **kwargs)

Bases: django.db.models.base.Model

Abstract model class for making manual relations between the differents entries.

class Meta
abstract = False
RelatedEntry.related
RelatedEntry.related_published

Returns only related entries published.

class zinnia.models.entry.TagsEntry(*args, **kwargs)

Bases: django.db.models.base.Model

Abstract lodel class to add tags to the entries.

Parameters:tags (TagField) – Tags
class Meta
abstract = False
TagsEntry.tags_list

Return iterable list of tags.

zinnia.models.entry.get_base_model()

Determine the base Model to inherit in the Entry Model, this allow to overload it.

Project Versions

Table Of Contents

Previous topic

admin Package

Next topic

spam_checker Package

This Page