用于内容分类的django可重用应用程序。

django-sitecats的Python项目详细描述


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

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

说明

django可重用的内容分类应用程序。

不,-你说,-所有的标签业务都缺乏结构化。

这个应用程序只是关于构建数据结构:构建类别层次结构并将站点实体链接到这些类别。

# Somewhere in views.pyfromdjango.shortcutsimportrender,get_object_or_404# Suppose Article model has sitecats.models.ModelWithCategory class mixed in.from.modelsimportArticledefarticle_details(self,request,article_id):"""See, there is nothing special in this view, yet it'll render a page with categories for the article."""returnself.render(request,'article.html',{'article':get_object_or_404(Article,pk=article_id)})defarticle_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.returnrender(request,'article.html',{'article':article,'form':form})

模板编码基本上可以归结为sitecats_categories模板标记用法:

<!-- 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. --><scriptsrc="{{ STATIC_URL }}js/sitecats/sitecats.min.js"></script><h1>{{ article.title }}</h1><divid="article_categories">
        {% sitecats_categories from article %} <!-- And that's it. --></div><!-- Form code goes somewhere here. -->
{% endblock %}

阅读文档,sitecats可以做更多。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
尝试在graphqljava下使用分析时出现NonNullableFieldWasNullError   键入如何在Java中将LocalDate列表添加到myList   java自定义授权取决于用户属性   java正在读一个。Eclipse中项目中的txt文件   java获取Hibernate Envers中实体的早期版本   java如何创建到枚举类型的映射?   java更改mockito间谍的字段   第一个元素添加到我的通用块列表时出现java空指针异常   使用SFTP和JSch:com的java连接问题。jcraft。jsch。JSchException   序列化Java:序列化对象时,我从我不尝试序列化的类中获取NotSerializableException   Android环境下java高效上传图像到服务器   JAVAlang.IllegalAccessError:尝试访问方法net。sourceforge。tess4j。特塞拉特<来自类Tess4jTest的init>()V。苔丝   java无法连接远程计算机上运行的服务   在名为“dispatcher”的DispatcherServlet中找不到URI为[/ecommerce.mvc/]的HTTP请求的java映射