Clone wiki

gnocchi-blog / Home

Overview

What is a blog, but a list of posts? That's what you get with Gnocchi Blog.

Requirements

  • Django 1.3+
  • django-taggit 0.8+

Setup

Just add to INSTALLED_APPS:

    'gnocchi.blog',
    'taggit',

URLs

Not every blog is the same, so not everyone wants the same URL patterns. So, the URL patterns can be configured. This is mostly for the Post.get_absolute_url method.

There are two settings to control which values are passed to revese():

BLOG_DATEBASED_URLS

Pass year, month and day:

  • 'year': '%04d' % self.post_date.year,
  • 'month': self.post_date.strftime('%b').lower(),
  • 'day': '%02d' % self.post_date.day,

BLOG_USERNAME_URLS

Passes the username of the poster.

These are passed, along with the posts slug, to reverse('blog-detail')

Comments

Supplied is a comments system very similar to the django.contrib.comments app, but including reCaptcha support. I would have left this out entirely, except there's no clean way to get at the request IP using the existing django.contrib.comments framework.

You will need to add two settings:

  • RECAPTCHA_PUBLIC_KEY
  • RECAPTCHA_SECRET_KEY

You can get these values by signing up with Google reCaptcha.

Templates

Tags

Just load the 'blog' library to access the following tags and filters.

{% get_recent_posts <n> [tag tag tag] [username=""] [as <varname>] %}

Retrieve the <n> most recent posts and put them (as a queryset) in context as 'post', or as the supplied variable name.

Optionally, filter by the supplied tags, or specified username. Note: be sure to put quotes around literal tag names, otherwise they'll be treated as context variable names and, if they don't exist, will be ignored.

Filters

As a shortcut, the "recent_posts" filter help when you want a simple, unfiltered loop. It assumes the value passed is a number, used to select how many posts to retrieve.

{% for post in "5"|recent_posts %} ...

Updated