Skip to main content

Django reusable application for content categorization.

Project description

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

LBC Python 2
https://img.shields.io/pypi/v/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

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

Uploaded Source

Built Distribution

django_sitecats-1.1.0-py2.py3-none-any.whl (36.8 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: django-sitecats-1.1.0.tar.gz
  • Upload date:
  • Size: 37.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for django-sitecats-1.1.0.tar.gz
Algorithm Hash digest
SHA256 59f3ad602254ecf57096f7889e70bd333ef7ed7168aaeb9677732614758e7ad2
MD5 8130ab5ff813a21d6bfed5c33eaac6c3
BLAKE2b-256 d2a9ba9649a83fd409a6073de1c4310e360bc1ad96a40e7ef26bc9f84180cf4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_sitecats-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b4003ac104dfa469aba5c2a2be3f57c3cf0571d85e5667e0c4a0ca624de8add4
MD5 eb21e0621bd21d7a0d687aaf5fcd9449
BLAKE2b-256 b6a858dbfe11ff5c7e46da255481f1d3fecc7da7e3c22eef44e0ac7fbfa1fd36

See more details on using hashes here.

Supported by

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