Reference

This document covers various components of pinax.apps.blog.

Settings

PINAX_ITEMS_PER_FEED

This setting is used to control how many items in a feed. Defaults to 20:

PINAX_ITEMS_PER_FEED = 50

MARKUP_CHOICES

A list of markup choices to make available in the blog. Defaults to an empty list. Available choices are: [("restructuredtext", u"reStructuredText"), ("textile", u"Textile"), ("markdown", u"Markdown"), ("creole", u"Creole")]

The actual origin of this setting is django-wikiapp which is one of the external applications Pinax integrates. pinax.apps.blog uses it to determine, how a post’s content should be converted from plain text to HTML.

MARKUP_CHOICES = [("textile", "Textile"), ("markdown", "Markdown")]

RESTRUCTUREDTEXT_FILTER_SETTINGS

Using this option you can pass additional settings as dictionary through the restructuredtext template library to the underlying docutils.core.publish_parts function. Defaults to empty dict.

RESTRUCTUREDTEXT_FILTER_SETTINGS = {}

BEHIND_PROXY

the users’ real IP addresses are stored when they create blog posts. When activated the blog takes the user’s IP address from request.META['HTTP_X_FORWARDED_FOR'] instead of request.META['REMOTE_ADDR']. Defaults to False.

BEHIND_PROXY = True

Named Urls

The named urls in this app should enable the use of of the {% url %} template tag as well as reverse lookups in your project code without having to know the implementation details of this app.

blog_post

Render a template with a specific blog post entry in context.

keyword arguments:
 (?P<username>[-\w]+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[-\w]+)

blog_list_all

Render a template with a queryset in context of all blog posts.

blog_list_user

Renders a template with a queryset in context of blog posts that are owned by a specified username.

keyword arguments:
 The username to list blog posts for matching (?P<username>\w+).

blog_list_yours

Renders a template with a queryset in context of blog posts that are owned by the logged in user.

blog_new

A GET request renders a template with a form instance in context. A POST request processes the data from this form and redirects user to blog_list_yours.

blog_edit

Upon a GET request a form is rendered to edit the blog entry. This urls also will process the POST request from submitting the form. After updating the post the response will be redirected to blog_list_yours.

arguments:The id for the blog post that matches (\d+).

blog_destroy

Delete a blog post that is yours on POST requests. Otherwise, it redirects the user to blog_list_yours.

arguments:The id for the blog post that matches (\d+).

blog_form_validate

Uses the ajax_validation app, it validates the blog post with the pinax.apps.blog.forms.BlogForm.

Templates

Templates should be placed in an blog/ folder at the root of one of your template search paths.

blogs.html

context:blogs

post.html

context:post

your_posts.html

context:blogs

new.html

context:blog_form

edit.html

context:blog_form, post

Modules

pinax.apps.blog.admin

class pinax.apps.blog.admin.PostAdmin(model, admin_site)
media

pinax.apps.blog.feeds

class pinax.apps.blog.feeds.BasePostFeed(slug, feed_url)
item_authors(post)
item_content(post)
item_id(post)
item_published(post)
item_title(post)
item_updated(post)
class pinax.apps.blog.feeds.BlogFeedAll(slug, feed_url)
feed_id()
feed_title()
feed_updated()
items()
class pinax.apps.blog.feeds.BlogFeedUser(slug, feed_url)
feed_id(user)
feed_title(user)
feed_updated(user)
get_object(params)
items(user)

pinax.apps.blog.forms

class pinax.apps.blog.forms.BlogForm(user=None, *args, **kwargs)
class Meta
model
alias of Post
BlogForm.clean_slug()
BlogForm.media

pinax.apps.blog.models

class pinax.apps.blog.models.Post(*args, **kwargs)

A model which holds a single post.

exception DoesNotExist
exception Post.MultipleObjectsReturned
Post.author
Post.get_absolute_url(*moreargs, **morekwargs)
Post.get_next_by_created_at(*moreargs, **morekwargs)
Post.get_next_by_publish(*moreargs, **morekwargs)
Post.get_next_by_updated_at(*moreargs, **morekwargs)
Post.get_previous_by_created_at(*moreargs, **morekwargs)
Post.get_previous_by_publish(*moreargs, **morekwargs)
Post.get_previous_by_updated_at(*moreargs, **morekwargs)
Post.get_status_display(*moreargs, **morekwargs)
Post.save(**kwargs)
pinax.apps.blog.models.new_comment(sender, instance, **kwargs)

pinax.apps.blog.templatetags.blog_tags

pinax.apps.blog.templatetags.blog_tags.show_blog_post(blog_post)

pinax.apps.blog.templatetags.creole

Provides the creole template filter, to render texts using the markup used by the MoinMoin wiki.

class pinax.apps.blog.templatetags.creole.CreoleTextNode(nodelist)
render(context)
pinax.apps.blog.templatetags.creole.creole(text, **kw)
Returns the text rendered by the Creole markup.
pinax.apps.blog.templatetags.creole.crl_tag(parser, token)
Render the Creole into html. Will pre-render template code first.

pinax.apps.blog.templatetags.restructuredtext

class pinax.apps.blog.templatetags.restructuredtext.ReStructuredTextNode(nodelist)
render(context)
pinax.apps.blog.templatetags.restructuredtext.flatpagehist_diff_previous(self)
pinax.apps.blog.templatetags.restructuredtext.rest_tag(parser, token)

Render the ReStructuredText into html. Will pre-render template code first.

Example:

{% restructuredtext %}
    ===================================
    To: {{ send_to }}
    ===================================
    {% include "email_form.rst" %}
{% endrestructuredtext %}
pinax.apps.blog.templatetags.restructuredtext.restructuredparts(value, **overrides)
return the restructured text parts
pinax.apps.blog.templatetags.restructuredtext.restructuredtext(value, **overrides)
The Django version of this markup filter has an issue when only one title or subtitle is supplied in that they are dropped from the markup. This is due to the use of “fragment” instead of something like “html_body”. We do not want to use “html_body” either due to some header/footer stuff we want to prevent, but we want to keep the title and subtitle. So we include them if present.
pinax.apps.blog.templatetags.restructuredtext.restructuredtext_has_errors(value, do_raise=False)
pinax.apps.blog.templatetags.restructuredtext.rstflatpage(context)

The core content of the restructuredtext flatpage with history, editing, etc. for use in your “flatpages/default.html” or custom template.

Example:

<html><head><title>{{ flatpage.title }}</title></head>
      <body>{% load restructuredtext %}{% rstflatpage %}</body>
</html>

This will inject one of 6 different page contents:

  • Just the flatpage.content for normal flatpages (so templates can be used with normal flatpages).
  • A custom 404 page (with optional create/restore form).
  • View current (with optional edit/history/delete form).
  • View version (with optional history/current/revert form).
  • Edit form (with preview/save/cancel).
  • History listing.
pinax.apps.blog.templatetags.restructuredtext.rstflatpage_feeds(context)
Optionally inserts the history feeds

pinax.apps.blog.templatetags.switchcase

Simplistic switch/case tag for Django.

Usage:

{% load switchcase %}
{% switch meal %}
    {% case "spam" %}...{% endcase %}
    {% case "eggs" %}...{% endcase %}
{% endswitch %}
class pinax.apps.blog.templatetags.switchcase.CaseNode(value, childnodes)
equals(otherval, context)
Check to see if this case’s value equals some other value. This is called from SwitchNode.render(), above.
render(context)
Render this particular case, which means rendering its child nodes.
class pinax.apps.blog.templatetags.switchcase.SwitchNode(value, cases)
render(context)
pinax.apps.blog.templatetags.switchcase.case(parser, token)
Case tag. Used only inside {% switch %} tags, so see above for those docs.
pinax.apps.blog.templatetags.switchcase.switch(parser, token)

Switch tag. Usage:

{% switch meal %}
    {% case "spam" %}...{% endcase %}
    {% case "eggs" %}...{% endcase %}
{% endswitch %}

Note that {% case %} arguments can be variables if you like (as can switch arguments, buts that’s a bit silly).

pinax.apps.blog.views

pinax.apps.blog.views.blogs(request, username=None, template_name='blog/blogs.html')
pinax.apps.blog.views.destroy(request, *args, **kwargs)
pinax.apps.blog.views.edit(request, *args, **kwargs)
pinax.apps.blog.views.new(request, *args, **kwargs)
pinax.apps.blog.views.post(request, username, year, month, slug, template_name='blog/post.html')
pinax.apps.blog.views.your_posts(request, *args, **kwargs)