blog package¶
Provides simple blog functionality. Article data is stored in blog.models.Article and can be rendered as django template.
Subpackages¶
Submodules¶
blog.admin module¶
blog.forms module¶
Forms for article app
-
class
blog.forms.ArticleAdminForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None)[source]¶ Bases:
django.forms.models.ModelFormBasic form for article change_view. Replaces text input with WYSISYG editor
blog.models module¶
This module defines models for blog app
-
class
blog.models.Article(*args, **kwargs)[source]¶ Bases:
django.db.models.base.ModelDescribes model for storing articles. Can render it’s content as Django template.
Article author, relates to
profiles.models.UserProfile
-
content¶ Article content. Can store html (including Django templates). Behaviour is defined by
is_django_template.
True if article is hidden from regular users. See
is_visible().
-
is_django_template¶ True if article should be rendered as Django template. See
rendered_content()
-
is_visible(user: django.contrib.auth.models.User)[source]¶ Checks if specified user van ciew this post. E.g. post is published, of user is staff & so on
Parameters: user (User) – User to be checked Returns: True if User can view this post, else False Return type: bool
-
publish_dttm¶ Publication Date and time. Auto populated at article creation.
-
rendered_content¶ Renders self.content as Django template.
Parameters: context (Context) – Additional context to be passed to template Returns: Rendered template
-
show_in_feed¶ True if article should appear in feeds such as
blog.views.ArticleList
-
slug¶ models.SlugFieldstoring user-friendly article URL
-
title¶ Article title.
Don’t insert HTML tags like <h3> - it’s rendered in templates. But, you may apply some text formatting like <b>.
blog.tests module¶
blog.urls module¶
URL dispatcher for blog app
Used urls:
* Empty url redirects to news feed. See blog.views.ArticleList
* post/<slug> and <slug> show detailed view of article (blog.views.ArticleDetail). The first one is kept to keep
old urls valid
blog.views module¶
-
class
blog.views.ArticleDetail(**kwargs)[source]¶ Bases:
django.views.generic.detail.DetailViewDetailed view of article.
Base template is
blog/article_detail.html.-
get_context_data(**kwargs)[source]¶ Raises 403 error if user can’t view this article. See
Article.is_visible()
-
model¶ alias of
Article
-
-
class
blog.views.ArticleList(**kwargs)[source]¶ Bases:
django.views.generic.list.ListViewBlog’s newsfeed. Shows all visible articles with
show_in_feed == TrueBase temlate is
blog/article_list.html.-
get_context_data(**kwargs)[source]¶ Returns list of articles to be shown in feed. See
blog.models.Articleparams for details
-
model¶ alias of
Article
-