django-articleappkit 0.3 documentation

Getting Started

Installation

Installation is easy using pip or easy_install.

pip install django-articleappkit

Simple Case

Article App Kit consists of abstract model factories. The model factory allows you to pass a configuration dictionary to set up each class. Django Article App Kit wasn’t meant to work by itself. So you will create a brand new app. We’ll call this app Story.

models.py

from articleappkit.models import (get_article_base, get_singleauthor_mixin,
                                   get_keyimage_mixin, get_pubworkflow_mixin)

ArticleBase = get_article_base()
SingleAuthorMixin = get_singleauthor_mixin()
KeyImageMixin = get_keyimage_mixin()
PubWorkflowMixin = get_pubworkflow_mixin()


class Story(ArticleBase, SingleAuthorMixin, KeyImageMixin, PubWorkflowMixin):
    """
    Creates a basic story model with a single author, related to auth.User,
    It has a Key Image and contains some useful publishing metadata.
    """
    pass

    class Meta:
        verbose_name_plural = u'stories'

In this simple case, we aren’t going to change any of the defaults. After we import several model factories, we call them to retrieve the classes. The Story class inherits from these classes, and nothing else is required except providing a proper verbose_name.

admin.py

from django.contrib import admin
from articleappkit.admin import (ArticleBaseAdmin, ARTICLE_BASE_FIELDSET,
                                  SINGLE_AUTHOR_FIELDSET, KEY_IMAGE_FIELDSET,
                                  PUBLISHING_FIELDSET)

from .models import Story


class StoryAdmin(ArticleBaseAdmin):
    fieldsets = (
        ARTICLE_BASE_FIELDSET,
        SINGLE_AUTHOR_FIELDSET,
        KEY_IMAGE_FIELDSET,
        PUBLISHING_FIELDSET,
    )
admin.site.register(Story, StoryAdmin)

urls.py

from django.conf.urls import patterns, url
from django.views.generic import DetailView, ListView

from .models import Story

urlpatterns = patterns('',
    url('^/', ListView.as_view(model=Story)),
    url('^/(?P<slug>[-\w]+)/$', DetailView.as_view(model=Story))
)

Modifying field names

You can override the default field names by adding a FIELDNAMES key to the ARTICLEAPPKIT_SETTINGS dictionary. Each key in the FIELDNAMES dictionary is the existing field name and the value is the new verbose name.

ARTICLEAPPKIT_SETTINGS = {
    'FIELDNAMES': {
        'title': 'headline',
        'key_image': 'primary image',
        'key_image_credit': 'primary image credit',
    }
}

Making your own settings

Pass your custom configuration to the

Adding WYSIWYG editors

Adding object relations