django-articleappkit v0.1 documentation
Article Builder only consists of abstract models. Therefore you will create a brand new app. We’ll call this app Story.
models.py
from articleappkit.models import (ArticleBase, SingleAuthorMixin,
KeyImageMixin, PublishingMixin)
class Story(ArticleBase, SingleAuthorMixin, KeyImageMixin, PublishingMixin):
"""
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'
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, include
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))
)
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',
}
}
This may have to be a v2 feature. The import logic is wonky as the model needs to import the settings in the module, and the final app imports the classes from the module.
Might try using a metaclass to allow importation of the settings by setting the settings module in the class like:
from storyapp import settings as story_settings