Skip to main content

Django reusable application for content categorization.

Project description

https://github.com/idlesign/django-sitecats

https://img.shields.io/pypi/v/django-sitecats.svg https://img.shields.io/pypi/dm/django-sitecats.svg https://img.shields.io/pypi/l/django-sitecats.svg https://img.shields.io/coveralls/idlesign/django-sitecats/master.svg https://img.shields.io/travis/idlesign/django-sitecats/master.svg https://landscape.io/github/idlesign/django-sitecats/master/landscape.svg?style=flat

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
    # 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:

<!-- 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 %}
    <!-- Some additional functionality (e.g. categories cloud rendering,
         editor enhancements) will require JS. -->
    <script src="{{ STATIC_URL }}js/sitecats/sitecats.min.js"></script>

    <h1>{{ article.title }}</h1>
    <div id="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

http://django-sitecats.readthedocs.org/

Project details


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.6.3.tar.gz (39.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_sitecats-0.6.3-py2.py3-none-any.whl (39.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-sitecats-0.6.3.tar.gz.

File metadata

File hashes

Hashes for django-sitecats-0.6.3.tar.gz
Algorithm Hash digest
SHA256 1090bb45edbcce1764bdd6b1037323de81026baf954e6bb785f61b357a2247ff
MD5 0ce2702d30b644447c664fd1c9857533
BLAKE2b-256 7a9e2a36ef263862ee8f93364a7d05d3560ef689c766a7f050f09dd8f450da06

See more details on using hashes here.

File details

Details for the file django_sitecats-0.6.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_sitecats-0.6.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1cfe4203ae19e889462e961f4bd8c9c2f4c988a8ba92a3e61f3505d073ae9504
MD5 c4bc25cda91d40fc59929b7b4c5c123a
BLAKE2b-256 4bf166840bc6a43cab24e07055066f9dd324f0fde42d07454d1f69acca2cfb6c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page