Skip to content

Commit

Permalink
Really fix the README
Browse files Browse the repository at this point in the history
  • Loading branch information
dmclain committed May 9, 2012
1 parent e218a31 commit b7562ce
Showing 1 changed file with 67 additions and 10 deletions.
77 changes: 67 additions & 10 deletions README.rst
Expand Up @@ -2,22 +2,79 @@ armstrong.apps.related_content
==============================
Provides mechanism for relating content to other models

.. warning:: This is development level software. Please do not unless you are
familiar with what that means and are comfortable using that type
of software.
You can use ``armstrong.apps.related_content`` to link two separate models
together through a ``GenericForeignKey`` for the ``source`` and the
``destination``. You can further organize the relationship with
``RelatedType`` (think: "articles", "images", "external_links", and so on) and
all relationships are ordered.


Usage
-----
You do *not* have to change your models to utilize related content---it exists
outside of your model. There are two fields that you can add that give you
easy access to your related content:

**TODO**
* ``armstrong.apps.related_content.fields.RelatedObjectsField``
* ``armstrong.apps.related_content.fields.ReverseRelatedObjectsField``

The first let's you access objects where your model is the ``source``, the
latter lets you access objects where your model is the ``destination``. Note
that these return the *actual* models that are related, not the
``RelatedContent`` model. If you need access to the raw ``RelatedContent``
model directly from your model, see
``armstrong.apps.related_content.fields.RelatedContentField``.

You can also use the ``RelatedContentInline`` for exposing an admin interface
to your related content inside Django's admin.


Accessing Related Content
"""""""""""""""""""""""""
You can access fields through the ``RelatedObjectsField`` or
``ReverseRelatedObjectsField`` by calling ``all()`` or
``by_type("some_type")``. These return QuerySet-like objects, but since they
are generic relationships, they're not quite QuerySets.

Inside templates, you can access related content by type using the dot-syntax.
For example, you could load the first related content of a type ``"articles"``
with this syntax:

::

{{ my_article.related.articles.0 }}

Installation
------------

Installation & Configuration
----------------------------
You can install the latest release of ``armstrong.apps.related_content`` using
`pip`_:

::

pip install armstrong.apps.related_content

Make sure to add ``armstrong.apps.related_content`` to your ``INSTALLED_APPS``.
You can add this however you like. This works as a copy-and-paste solution:

::

name="armstrong.apps.related_content"
pip install -e git://github.com/armstrong/$name#egg=$name
INSTALLED_APPS += ["armstrong.apps.related_content", ]

Once installed, you have to run either ``syncdb``, or ``migrate`` if you are
using `South`_.

.. _pip: http://www.pip-installer.org/
.. _South: http://south.aeracode.org/


Backwards Incompatible Changes
------------------------------

*Version 2.0*
* ``RelatedObjectsField`` no longer extends
``genericm2m.models.RelatedObjectsDescriptor``.
* All fields have been been moved into the ``fields`` module now.


Contributing
Expand All @@ -39,7 +96,7 @@ 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`_. The first release is scheduled for June, 2011.
Foundation`_.

To follow development, be sure to join the `Google Group`_.

Expand All @@ -55,7 +112,7 @@ probably looking for that.

License
-------
Copyright 2011 Bay Citizen and Texas Tribune
Copyright 2011-2012 Bay Citizen and Texas Tribune

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down

0 comments on commit b7562ce

Please sign in to comment.