尽管这两个链接完全相同,但我一直收到"Page Not Found at /account/login/next?“每当我单击我的链接时都会出错。我的代码中的错误是什么?“探索”行得通,但“发生”不行!请帮帮我!
views.py
def explore(request):
return render(request, 'explore.html')
def happening(request):
return render(request, 'happening.html')html模板
<div id="happening_log">
<a style= "padding-left:5px" href="{% url 'happening'
%}">Happening</a>
</div>urls.py
urlpatterns = [
path('', views.explore, name='explore'),
path('<user__name>/', views.home, name='home'),
path('happening/', views.happening, name='happening'),
]页面未找到(404)请求方法: GET请求URL:http://127.0.0.1:8000/accounts/login/?next=/happening/使用mysite.urls中定义的URLconf,Django按以下顺序尝试了这些URL模式:
admin/
[name='explore']
<user__name>/ [name='home']
/happening/ [name='happening']
users/
^static\/(?P<path>.*)$
^media\/(?P<path>.*)$
The current path, accounts/login/, didn't match any of these.发布于 2019-02-08 09:09:37
您是否在项目站点中创建了注册/login.html文件?url,http://127.0.0.1:8000/accounts/login/?next=/happening/正在访问登录模板,因此您必须创建一个默认的注册/login.html或类似下面的另一个登录;
def login(request):
if request.method == 'POST':
form = LoginForm(request.POST)
if form.is_valid():
username=form.cleaned_data.get('username')
password=form.cleaned_data.get('password')
user = authenticate(username=username, password=password)
if user and user.profile.status == 'WORKING':
auth.login(request, user)
if user.profile.passwd:
return redirect('myprofile')
else:
return redirect('password')
else:
form = LoginForm()
return render(request, 'accounts/login.html', {'form': form})https://stackoverflow.com/questions/54582006
复制相似问题