python编程django遇到问题Passing a 3-tuple to include() is not supported.解决方案
文章目錄
- 遇到的問題
- 解決方法
- 參考
遇到的問題
(ll_env) PS D:\user\文檔\python\python_work\learning_log> python manage.py runserver
Watching for file changes with StatReloader
Performing system checks…
Exception in thread django-main-thread:
Traceback (most recent call last):
File “D:\user\文檔\python\python_work\learning_log\ll_env\lib\site-packages\django\urls\conf.py”, line 17, in include
urlconf_module, app_name = arg
ValueError: too many values to unpack (expected 2)
以及后面的
django.core.exceptions.ImproperlyConfigured: Passing a 3-tuple to include() is not supported. Pass a 2-tuple containing the list of patterns and app_name, and provide the namespace argument to include() instead.
相關的代碼是《python編程從入門到實踐》里面的例程
from django.contrib import admin from django.conf.urls import include, urlurlpatterns = [url(r'^admin/', include(admin.site.urls)),url(r'', include('learning_logs.urls', namespace = 'learing_logs')), ]解決方法
將上述代碼更改為
from django.contrib import admin from django.conf.urls import include, urlurlpatterns = [url(r'^admin/', admin.site.urls),url(r'', include(('learning_logs.urls', 'learning_logs'), namespace = 'learing_logs')), ]請注意:這里參考的是下面的博文,對原作者表示感謝。
運行成功
參考
[1]https://blog.csdn.net/m0_38059875/article/details/82793269
總結
以上是生活随笔為你收集整理的python编程django遇到问题Passing a 3-tuple to include() is not supported.解决方案的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CSP认证202012-2期末预测之最佳
- 下一篇: python项目NoReverseMat