Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/idlesign/django-sitecats
Django reusable application for content categorization.
https://github.com/idlesign/django-sitecats
categories django navigation python tagcloud tags
Last synced: 4 days ago
JSON representation
Django reusable application for content categorization.
- Host: GitHub
- URL: https://github.com/idlesign/django-sitecats
- Owner: idlesign
- License: bsd-3-clause
- Created: 2014-02-24T13:03:24.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-02-04T12:37:30.000Z (almost 3 years ago)
- Last Synced: 2024-10-04T13:31:21.781Z (about 1 month ago)
- Topics: categories, django, navigation, python, tagcloud, tags
- Language: Python
- Homepage: https://github.com/idlesign/django-sitecats
- Size: 177 KB
- Stars: 19
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
django-sitecats
===============
https://github.com/idlesign/django-sitecats.. image:: https://img.shields.io/pypi/v/django-sitecats.svg
:target: https://pypi.python.org/pypi/django-sitecats.. image:: https://img.shields.io/pypi/l/django-sitecats.svg
:target: https://pypi.python.org/pypi/django-sitecats.. image:: https://img.shields.io/coveralls/idlesign/django-sitecats/master.svg
:target: https://coveralls.io/r/idlesign/django-sitecatsDescription
-----------*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.
.. code-block:: python
# 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 Articledef 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
# to add subcategories to `language`, and `os` categories
# (suppose we created them beforehand with Admin contrib),
# and link this article to them.
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:
.. code-block:: html
{% extends "base.html" %}
{% load sitecats %}{% block contents %}
{{ article.title }}
{% sitecats_categories from article %}
{% endblock %}Read the docs, ``sitecats`` can do more.
Documentation
-------------https://django-sitecats.readthedocs.org/