Django reusable application for content categorization.
Project description
https://github.com/idlesign/django-sitecats
Description
Django reusable application for content categorization.
Nay, - you say, - all that tags business lacks structuring.
This application is just about structuring your data: build categories hierarchy and link your site entities to those categories.
# Somewhere in views.py
from django.shortcuts import render, get_object_or_404
# Suppose Article model has sitecats.models.ModelWithCategory class mixed in.
from .models import Article
def article_details(self, request, article_id):
"""See, there is nothing special in this view, yet it'll render a page with categories for the article."""
return self.render(request, 'article.html', {'article': get_object_or_404(Article, pk=article_id)})
def article_edit(self, request, article_id):
"""Let's allow this view to render and handle categories editor."""
article = get_object_or_404(Article, pk=article_id)
# Now we enable category editor for an article, and allow users
# not only to link that article to subcategories of `language`, and `os` categories,
# but also to add those subcategories.
article.enable_category_lists_editor(request,
editor_init_kwargs={'allow_new': True},
additional_parents_aliases=['language', 'os'])
form = ... # Your usual Article edit handling code will be here.
return render(request, 'article.html', {'article': article, 'form': form})
Template coding basically boils down to sitecats_categories template tags usage:
<!-- The same html is just fine for demonstration purposes for both our views.
Do not forget to load `sitecats` template tags library. -->
{% extends "base.html" %}
{% load sitecats %}
{% block contents %}
<h1>{{ article.title }}</h1>
<div class="article_categories">
{% sitecats_categories from article %} <!-- And that's it. -->
</div>
<!-- Form code goes somewhere here. -->
{% endblock %}
Read the docs, sitecats can do more.
Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-sitecats-0.1.0.tar.gz
(25.5 kB
view details)
File details
Details for the file django-sitecats-0.1.0.tar.gz
.
File metadata
- Download URL: django-sitecats-0.1.0.tar.gz
- Upload date:
- Size: 25.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
a59e6aebb8d49835a2728620b0e2781f28a49167fec10c001cda99b6bed494e9
|
|
MD5 |
b5aae84ce111607372bd08a0ae49222a
|
|
BLAKE2b-256 |
0e2dc6ecf7a08078054ff4f53fb83e97e8636999e936e6739794fd63a4373381
|