本文介绍了如何使用django-sitetree?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用,但我不明白如何做步骤3,它是:

I am trying to use django-sitetree but I don't understand how to do step 3 which is:

转到Django管理站点并添加一些树木树项目。

"Go to Django Admin site and add some trees and tree items."

在管理面板中做一个sitetree?我相信第一步是为您要添加的网站树选择一个别名。

How to make a sitetree in the admin panel? I believe the first step is to choose an alias for the "Site Tree" you are about to add.

下一步是添加网站树项目。在这个页面上,你必须选择父母,标题,网址。考虑到我的应用程序是动态的url结构像这样 localhost:8000 / categoryname / entryname 如何选择网址?

The next step is to add "Site Tree Item". On this page you have to choose parent, title, url. Considering my app is dynamic with url structure like this localhost:8000/categoryname/entryname how do I choose urls?

我正在尝试在我的模板中添加面包屑。

By the way I am trying to add breadcrumbs in my templates.

推荐答案

创建一个树:


  1. 转到站点管理面板;

  2. 点击+添加附近'站点树';

  3. 为您的sitetree输入别名,例如'maintree'。

    你将通过模板标签中的这个别名来处理你的树;

  4. 按添加网站树项;

  5. 创建第一个项目:

  1. Goto site administration panel;
  2. Click +Add near 'Site Trees';
  3. Enter alias for your sitetree, e.g. 'maintree'.
    You'll address your tree by this alias in template tags;
  4. Push 'Add Site Tree Item';
  5. Create first item:


  • 创建第二个项目(将从你的'categoryname / entryname'处理'categoryname') :

  • Create second item (that one would handle 'categoryname' from your 'categoryname/entryname'):


  • 创建第三个项目(将处理'

  • Create third item (that one would handle 'entryname' from your 'categoryname/entryname'):


  • 将{%load sitetree%}放入yor模板以访问sitetree标签。


  • 将{%sitetree_breadcrumbs frommaintree%}放入您的模板中以渲染面包屑。






  • 步骤6和7需要一些说明:


    Steps 6 and 7 need some clarifications:


    • 在标题中,我们使用Django模板变量,它将像在模板中一样被解析。

    • In titles we use Django template variables, which would be resolved just like they do in your templates.


  • 在URL中,我们使用Django的命名网址格式()。这几乎与使用Django的标签几乎相同在模板中。

  • In URLs we use Django's named URL patterns (documentation). That is almost idential to usage of Django 'url' tag in templates.

    url (r'^(?P< category_name> \S +)/(?P< entry_name> \S +)/ $','detailed_entry',name ='条目详细 br>
    url(r'^(?P< category_name> \S +)/ $','detailed_category',name ='类别详细'),

    url(r'^(?P<category_name>\S+)/(?P<entry_name>\S+)/$', 'detailed_entry', name='entry-detailed'),
    url(r'^(?P<category_name>\S+)/$', 'detailed_category', name='category-detailed'),

    因此,将第7步中的entry-detailed category.name entry.name放入URL字段,我们告诉sitetree将该sitetree项目与名为entry-detailed的URL相关联,传递给它category_name和entry_name参数。

    So, putting 'entry-detailed category.name entry.name' in step 7 into URL field we tell sitetree to associate that sitetree item with URL named 'entry-detailed', passing to it category_name and entry_name parameters.


  • 我希望这个描述应该填写文档差距% )

    I hope this description should fill the documentation gap %)

    这篇关于如何使用django-sitetree?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    10-29 01:49