runserver命令发生以下错误: 在模板C:\ Users \ V \ Downloads \ DJANGO \ blog_project \ mysite \ blog \ templates \ blog \ base.html中,第26行出现错误
Line 26 in base.html is:
<li><a href="{% url 'about' %}">About</a></li>
In App's URL file:
url(r'^about', views.AboutView.as_view(), name='about')
path('about',views.AboutView.as_view(), name='about'),
Tried both with and without $ sign.
And in views.py file
class AboutView(TemplateView):
template_name = 'about.html'
以下是应用程序,因为我们作为项目文件的网址 应用程式网址档案: 从django.urls导入路径 从django.conf.urls导入URL 来自。导入视图
urlpatterns = [
url(r'^$', views.PostListView.as_view(), name='post_list'),
url(r'^about', views.AboutView.as_view(), name='about'),
#path('about/',views.AboutView.as_view(), name='about'),
url(r'^post/(?P<pk>\d+)$', views.PostDetailView.as_view(), name='post_detail'),
url(r'^post/new/$', views.CreatePostView.as_view(), name='post_new'),
url(r'^post/(?P<pk>\d+)/edit/$', views.PostUpdateView.as_view(), name='post_edit'),
url(r'^post/(?P<pk>\d+)/remove/$', views.PostDeleteView.as_view(), name='post_remove'),
url(r'^drafts/$', views.DraftListView.as_view(), name='post_draft_list'),
url(r'^post/(?P<pk>\d+)/comment/$', views.add_comment_to_post, name='add_comment_to_post'),
url(r'^comment/(?P<pk>\d+)/approve/$', views.comment_approve, name='comment_approve'),
url(r'^comment/(?P<pk>\d+)/delete/$', views.comment_remove, name='comment_remove'),
url(r'^post/(?P<pk>\d+)/publish/$', views.post_publish, name='post_publish'),
]
project URL (mysite)
from django.contrib import admin
# from django.urls import path, include
from django.conf.urls import url, include
from django.contrib.auth import views
urlpatterns = [
url(r'$', include('blog.urls')),
url(r'^admin/', admin.site.urls),
url(r'^accounts/login/', views.LoginView.as_view(template_name='login.html'), name='login'),
url(r'^accounts/logout/', views.LogoutView.as_view(), name='logout', kwargs={'next_page': '/'}),
]
答案 0 :(得分:0)
请遵循以下所示的模式:对于旧版本的django,请使用第一个。
df.train.age.apply(lambda x:0 if x>=0 and x<500 else 0)