Using the contrib.people module

Manage people/authors and link them to content via M2M relations.

Installation

INSTALLED_APPS = [
    "djangocms_custom_content",
    "djangocms_custom_content.contrib.people",
]
python manage.py migrate

Models

Person - Groups all language versions of a person PersonContent - Language-specific person information (name, bio, etc.)

Usage

Creating people:

from djangocms_custom_content.contrib.people.models import Person, PersonContent

person = Person.objects.create()
PersonContent.objects.create(
    person=person,
    language="en",
    first_name="John",
    last_name="Doe",
    bio="Author bio...",
)

Linking to content:

# In your BlogPost model
class CMSConfig:
    m2m_relations = [("authors", "blog.BlogPost")]

# Use it
blog_post = BlogPost.objects.first()
blog_post.authors.all()  # Get all authors
blog_post.authors.add(person_content)

In templates:

{% for person in article.authors.all %}
    <div class="author">
        <h4>{{ person.first_name }} {{ person.last_name }}</h4>
        <p>{{ person.bio }}</p>
    </div>
{% endfor %}

Plugins

PersonTeaser - Display a single person PersonList - Display a list of people

Admin

Registered in Django admin with inline editing.

See Also