I have a Django project with several applications, and I want to add the Django admin site for one of these.
The problem I have is that the main urls.py
file has
url(r'^tools/(\w+)/', include('tools.myapp.urls')),
and in my myapp.urls
I have added
url(r'^admin/', include(admin.site.urls)),
The problem is that the parent part of the url matching uses a parameter, which is usually passed in the template (that's the application name) like so
{% url "my_view_function" request.info.appname %}
But the default Django template obviously don't include that extra parameter, when calling
{% url 'admin:logout' %}
thus leading to a NoReverseMatch
exception.
How can I have the admin site working?
如果您只想让admin在任何工具/任何/管理URL下运行,则可以在tools.myapp.urls
导入主urls.py中之前添加以下行:
url(r'^tools/\w+/admin/', include(admin.site.urls)),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.