Blog Archive for November 22, 2009

Django Tagging

November 22, 2009

Django has built in tagging functionality. You can add tags to a model, and then manipulate them in common ways.

models.py

from tagging.fields import TagField

# add this to the model
tags = TagField()

def tag_words(self):
    return self.tags.split(' ') …

Django Atom Feeds

November 22, 2009

Django has built in support for exposing Atom feeds

feeds.py

Create a feeds.py in the app you want to export feeds from.

from django.utils.feedgenerator import Atom1Feed
from django.contrib.sites.models import Site
from django.contrib.syndication.feeds import Feed
from site.blog.models import Blog

current_site = Site.objects.get_current()

class LatestEntriesFeed(Feed …

Django Comments Moderation

November 22, 2009

Django comments allow you to set up moderation options.

models.py

In your models.py that you have comments for

from django.contrib.comments.moderation import CommentModerator, moderatorclass

BlogModerator(CommentModerator):
    email_notification = True
    enable_field = 'enable_comments'
    auto_moderate_field = 'publication_date'
    moderate_after = 14

moderator.register(Blog, BlogModerator)

This sets …