【发布时间】:2020-04-22 08:59:45
【问题描述】:
如何修复页面未找到(404)错误 django2.0 的配置文件页面
这段代码
查看代码
'''
def profile(request, slug):
profile = Profile.objects.get(slug=slug)
context = {
'profile':profile,
}
return render(request, 'registration/profile.html' ,context)
''' 和这个 urls.py
'''
from django.urls import path,re_path
from . import views
from django.contrib.auth.views import LoginView,logout #login
app_name='accounts'
urlpatterns = [
path(r'', views.home, name ='home'),
# path(r'^login/$', login, {'template_name':'registration/login.html'}),
path('login/', LoginView.as_view(), name="login"),
path(r'^logout/$', logout, name='logout'),
# path(r'^signup/$', views.register, name='register'),
path('signup/', views.register, name='signup'),
path(r'^(?P<slug>[-\w]+)/$', views.profile, name='profile'),
# path(r'^(?P<slug>[-\w]+)/edit$', views.edit_profile, name='edit_profile'),
]
'''
模板/注册文件夹中的profile.html页面
【问题讨论】:
-
请在提问时包含完整的错误信息。目前我们无法确定是哪个 URL 为您提供了 404。