小编wr3*_*yth的帖子

include()得到一个意外的关键字参数'app_name'

我正在使用django-2.0为我的网站制作一个博客应用程序,当我运行服务器时,我看到以下错误

File "C:\Users\User\Desktop\djite\djite\djite\urls.py", line 7, in <module>
url(r'^blog/', include('blog.urls', namespace='blog', app_name='blog')),
TypeError: include() got an unexpected keyword argument 'app_name'
Run Code Online (Sandbox Code Playgroud)

这是我的主要urls.py

from django.contrib import admin
from django.conf.urls import url,include

urlpatterns = [
    url(r'^admin/', admin.site.urls),

    url(r'^blog/', include('blog.urls', namespace='blog', app_name='blog')),
]
Run Code Online (Sandbox Code Playgroud)

这是我的博客/ urls.py

from django.conf.urls import url
from . import views
urlpatterns = [
    url(r'^$', views.post_list, name='post_list'),
    url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>d{2})/(?P<post>
    [-/w]+)/$', views.post_detail, name='post_detail'),
    ]
Run Code Online (Sandbox Code Playgroud)

我的views.py:

from django.shortcuts import render, HttpResponse, get_object_or_404
from blog.models import Post
def post_list(request): #list
posts=Post.published.all()
return render(request, 'blog/post/list.html', {'posts': posts})

def …
Run Code Online (Sandbox Code Playgroud)

django django-models django-urls django-views django-2.0

7
推荐指数
1
解决办法
4423
查看次数