Boilerplate for taxonomies, content collections, and content models using django-mptt and django-taggit.
Features
Drag and drop construction of taxonomies.
Arbitrary relationships among groups, taxonomies, collections, content, and attachments.
Templates for displaying taxonomies with and without collections’ contents.
Documentation
dj-content model is just boilerplate for django-mptt and django-taggit. It defines a hierarchical structure with arbitrary relationships via collections. The Quickstart example is a sufficient starting point for many projects. Each abstract class provided by dj-contentmodel is a descendant of django.db.models, so extend them as you would a Django model. The Group and Taxonomy classes are also descendants of django-mptt’s MPTTModel class and can be extended accordingly. Additional examples dj-contentmodel’s abstract classes are available at https://dj-contentmodel.readthedocs.org.
Quickstart
First, install dj-contentmodel:
pip install dj-contentmodel
Then, import the abstract base classes.:
from dj_contentmodel.models import Taxonomy, Collection, Content, Attachment
Next, subclass the imported classes to create taxonomies and content models as needed. The following example is of a minimum configuration. The names of defined classes are arbitrary, but the relationships among classes are not.
class Sitemap(Taxonomy):
"""Main navigation"""
collections = models.ManyToManyField('Bucket', blank=True)
class Meta:
verbose_name = "Category"
verbose_name_plural = "Categories"
...
class Bucket(Collection):
"""Arbitrary collections to group content."""
contents = models.ManyToManyField('Page', blank=True)
...
class Page(Content):
...
class Report(Attachment):
parents = models.ManyToManyField('Page', blank=True)
...
Finally, register your models with the admin.
from django.contrib import admin
from mptt.admin import DraggableMPTTAdmin
admin.site.register(
Sitemap,
DraggableMPTTAdmin,
list_display=(
'tree_actions',
'indented_title',),
list_display_links=(
'indented_title',),)
admin.site.register(Bucket)
admin.site.register(Page)
admin.site.register(Report)
Without a migration, it may be necessary to create the tables.:
python manage.py migrate --run-syncdb
Running Tests
Does the code actually work? For now I have my fingers crossed. Later iterations will be test driven and include integration and performance testing.
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install -r requirements_test.txt (myenv) $ python runtests.py
Credits
Tools used in rendering this package:
History
0.1.0 (2016-06-07)
First release on PyPI.
Metadata
Release files for dj-contentmodel 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dj-contentmodel-0.1.7.tar.gz | 6.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dj_contentmodel-0.1.7-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 14.6 kB
Release files / dj-contentmodel-0.1.7.tar.gz
| Download URL | dj-contentmodel-0.1.7.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4665c9e58e822f57a89653393d7ae7590db5cd7c535e50d8661721673611d6b
|
|
BLAKE2b-256 checksum How to use checksums |
668d9f2f5e3c9b46671a251e39a45a06e22f95985c7900232a1e3e3ccf14b50d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / dj_contentmodel-0.1.7-py2.py3-none-any.whl
| Download URL | dj_contentmodel-0.1.7-py2.py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f54d55a26c8deadd03483d7f23db5969842ebddf2fd604ac91397d7d314f0a5b
|
|
BLAKE2b-256 checksum How to use checksums |
76101a844c08dfafb05f7cc915d04c19d86694f7a52c3027924aff9cf6825907
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for dj-contentmodel 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.