Skip to main content
Help us improve Python packaging – donate today!

Provides hierarchical taxonomy for content

Project Description

TravisCI status Coverage status PyPI Version License

Provides content categorization within an Armstrong site.

The Section model provides hierarchical organization for content, or really for anything you’d like to organize. In the Armstrong ecosystem we organize articles. For example, the Texas Tribune has an Immigration section which in turn has Sanctuary Cities and Dream Act as children sections. Like a typical tree structure, anything belonging to a child also belongs to the parent. You can also ignore the hierarchy and create a flat structure.

ArmSections also provides a basic View for items in a section and a template tag for displaying (and linking to) all the sections. Also available is a Feed view, an Admin display mixin and a queryset manager for use on the content items. These aren’t documented as they should be…


Add a section field to any model that you would like to show up in a given section.

from django.db import models
from armstrong.core.arm_sections.models import Section

class MyArticle(models.Model):
    title = models.CharField(max_length=100)
    body = models.TextField()
    section = models.ForeignKey(Section)

You can also relate to multiple sections through a ManyToManyField:

class MyArticle(models.Model):
    sections = models.ManyToManyField(Section)

Sections are designed to hold items of a single model type (or a single parent type, inheritance is fine. Actually inheritance is one of ArmSections’ strengths). If you aren’t using the armstrong.apps.content companion package, you’ll need to set ARMSTRONG_SECTION_ITEM_MODEL in settings.

On the other side of the relationship, Sections have items and published attributes that allow different access to the associated content. These attributes are powered by configurable backends for flexibility so you can tailor the lookup. For example, “published” might mean a non-draft flag on the content or a combination of flag and date; swap the published backend to meet the need.

ItemFilter and PublishedItemFilter are the defaults and tie into managers used in the companion (but not required) armstrong.core.arm_content. They also know about django-model-utils InheritanceManager and will utilize select_subclasses() if available.

Displaying Sections

You can display a section through the SimpleSectionView class-based-view (CBV). First, setup a named URL route:


Then use the {% section_menu %} template tag to display a list of all sections inside your template. {% load section_helpers %} first to use the template tag and provide a section_view kwarg that is the named URL route associated with your section view. Putting it together:

{% load section_helpers %}
{% section_menu section_view='section_view' %}

With the following sections in your database…


…and the example so far, the output from your template would look like this:

<ul class="root">
        <a href='/section/politics/'>Politics</a>
        <a href='/section/sports/'>Sports</a>
        <ul class="children">
                <a href='/section/sports/football/'>Football</a>
                <a href='/section/sports/basketball/'>Basketball</a>
        <a href='/section/fashion/'>Fashion</a>

Installation & Configuration

Supports Django 1.3, 1.4, 1.5, 1.6, 1.7 on Python 2.6 and 2.7. (Though if you are using Django 1.3, make sure to use django-mptt<0.6.)

  1. pip install armstrong.core.arm_sections
  2. Add armstrong.core.arm_sections to your INSTALLED_APPS
  3. Install the database schema
    • Django 1.7+ use migrate
    • previous Djangos use either syncdb or migrate if you are using South (in which case use South 1.0+)

Optional Settings: (Used in

There are three settings that you can use to change the behavior of this component and its relation to content items.

This is used to configure which backend is used to find the items associated with a given Section. (default: armstrong.core.arm_sections.backend.ItemFilter)
Same as ITEM_BACKEND except it is designed for limiting to published items. (default: armstrong.core.arm_sections.backend.PublishedItemFilter)
Used by the two default backends to determine which model has a section associated with it. (default: armstrong.apps.content.models.Content)


Development occurs on Github. Participation is welcome!

  • Found a bug? File it on Github Issues. Include as much detail as you can and make sure to list the specific component since we use a centralized, project-wide issue tracker.
  • Testing? pip install tox and run tox
  • Have code to submit? Fork the repo, consolidate your changes on a topic branch and create a pull request. The package provides tools for testing, coverage and South migration as well as making it very easy to run a full Django environment with this component’s settings.
  • Questions, need help, discussion? Use our Google Group mailing list.

State of Project

Armstrong is an open-source news platform that is freely available to any organization. It is the result of a collaboration between the Texas Tribune and Bay Citizen and a grant from the John S. and James L. Knight Foundation. Armstrong is available as a complete bundle and as individual, stand-alone components.

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node

History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node

History Node

History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
armstrong.core.arm_sections-1.6.0.tar.gz (15.0 kB) Copy SHA256 hash SHA256 Source None Sep 8, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page