【发布时间】:2021-04-02 19:20:54
【问题描述】:
在我将模板添加到最小的 web 应用程序后,问题出现了。模板extends django-oscar 的layout.html。项目中没有其他内容extendslayout.html。
我的目标只是能够使用 django-oscar 模板在我的 webapp 中形成网页的基础。出于某种原因,我的问题没有尽头。这只是最新的错误消息。这几天我一直在为此苦苦挣扎!当我解决一个问题时,会出现另一个问题。
我为这个问题做了一个最小的 git repo:https://github.com/mslinn/django_oscar_problem
repo 有一个requirements.txt 文件,以防有人想要安装运行程序所需的 PIP 模块。
我试图确保我有最简单的项目来显示问题。在README.md 中,我显示了在网络浏览器中显示的完整错误消息。
# /templates/welcome.html
{% extends 'oscar/layout.html' %}
... etc ...
# main/urls.py
from django.urls import include, path
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('', views.home, 'home'),
path('admin/', admin.site.urls, 'admin'),
path('hello/', views.hello, 'hello'),
path('', include(apps.get_app_config('oscar').urls[0])),
]
# main/views.py
from django.shortcuts import render
def home(request):
return render(request, "welcome.html", {})
然后我运行 webapp:
$ ./manage.py runserver
访问http://localhost:8000后网页浏览器中的错误信息是:
ValueError at /
dictionary update sequence element #0 has length 1; 2 is required
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 3.1.6
Exception Type: ValueError
Exception Value:
dictionary update sequence element #0 has length 1; 2 is required
【问题讨论】:
标签: django django-oscar