英文:
Updating urlpatterns for django-smart-selects
问题
我正在尝试构建我的第一个Django项目,基于Django文档中的投票示例。
我想要在表单中添加链接/级联下拉菜单,并找到了django-smart-selects。
我阅读了文档,但不确定如何将文档中建议的更新集成到我目前的项目的urls.py urlpatterns中。
链接文档中提到的智能选择URL:
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^chaining/', include('smart_selects.urls')),
)
我项目中urls.py文件中当前的urlpatterns值:
urlpatterns = [
path('', include('TimeTracking.urls')),
path('admin/', admin.site.urls),
path('data-browser/', include('data_browser.urls')),
]
显然,将这些条目添加到我的urlpatterns = []中不会起作用,但我还是尝试了一下...
NameError: name 'url' is not defined
英文:
I am attempting my first django project by building on top of the polls example from the django documentation.
I would like to add linked/cascading dropdowns to a form and found my way to django-smart-selects.
I read the documentation but wasn't sure how to integrate the suggested updates to project's urls.py urlpatterns from the documentation into what I have currently.
The smart select urls mentioned in the linked documentation
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^chaining/', include('smart_selects.urls')),
)
The current value of urlpatterns in my project's ursl.py file.
urlpatterns = [
path('', include('TimeTracking.urls')),
path('admin/', admin.site.urls),
path('data-browser/', include('data_browser.urls')),
]
Obviously adding those entries to my urlpatterns = [] wouldn't work but I attemtped it anyway...
> NameError: name 'url' is not defined
答案1
得分: 0
from django.urls import path, re_path
urlpatterns = [
path('', include('TimeTracking.urls')),
path('admin/', admin.site.urls),
re_path(r'^chaining/', include('smart_selects.urls')),
path('data-browser/', include('data_browser.urls')),
]
英文:
try
from django.urls import path, re_path
urlpatterns = [
path('', include('TimeTracking.urls')),
path('admin/', admin.site.urls),
re_path(r'^chaining/', include('smart_selects.urls')),
path('data-browser/', include('data_browser.urls')),
]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论