我在SiteTree配置中遇到URL模式问题。我已经阅读了手册:https : //django-sitetree.readthedocs.org/ru/latest/quickstart.html因此,我尝试使用命名URL来制作我的树:app / urls.py:urlpatterns = patterns('',.....url('^dict/persons/(?P<person_id>\d+)/$', persondetail, name = 'persondetail'),.....)SiteTree项目配置:Title: 'Person detail'URL: 'app:persondetail person.id'网址为格式(已选中)结果很差-SiteTree菜单无法正常工作-它不会呈现菜单元素和面包屑。在其他页面上也可以。我也试图写像URl模式: - 'app:persondetail person.id' - 'app:persondetail person_id' - 'app:persondetail Person.id' - 'app:persondetail Person_id' - 'app:persondetail {{person.id}}' - 'app:persondetail {{Person.id}}' - 'app:persondetail #person.id' - 'app:persondetail #Person.id' - with quotes and without但是它仍然无法正常工作。我的项目结构为:- project |___main_app | |___urls.py: | from django.conf.urls import patterns, include, url | from django.contrib import admin | admin.autodiscover() | | urlpatterns = patterns('', | url(r'^', include('app.urls', namespace="app")), | url(r'^admin/', include(admin.site.urls)), | ) | |___app |___urls.py: | from django.conf.urls import patterns, include, url | from jdevtool.views import * | | urlpatterns = patterns('', | ..... | url('^dict/persons/(?P<person_id>\d+)/$', persondetail, name = 'persondetail'), | ..... | | ) | |___views.py: ..... def persondetail(request, person_id): pers = get_object_or_404(Person, pk=person_id) return render(request, 'app/persDetail.html', {'pers': pers}) .....
添加回答
举报
0/150
提交
取消