我不知道为什么寄存器表单中的变量没有存储在django管理页面中!我很困惑。谢谢您阅读本文,我非常感谢。 :)
// htmlsnippet.html
{% block content %}
<h1>Sign up</h1>
<form class ="site-form" action="register/" method="post">
{% csrf_token %}
{{form}}
<input type="submit" value="Signup">
</form>
{% endblock %}
// home.html
{% extends "register/header.html" %}
{% block content %}
{% include "register/includes/htmlsnippet.html" %}
{% endblock %}
// views.py
from django.shortcuts import render,redirect
from django.http import HttpResponse
from django.contrib.auth.forms import UserCreationForm
# Create your views here.
def index(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
form.save()
return redirect("/personal")
else:
form = UserCreationForm()
return render(request, 'register/home.html',{'form':form})
好吧,因为该表格在网站上。问题是,当我在这些输入中输入值时,它不会保存在管理员中。这是我的注册网址(
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^', views.index, name='index')#,url(r'^register', views.post, name='post')
]
“)
这是我的网址格式。
urlpatterns = [
url(r'^register/$', include('register.urls'))