如何让我的表单出现?
到目前为止,只显示了html标题和提交按钮。
Views.py :
from django.shortcuts import render
# Create your views here.
from signups.forms import SignUpForm
def home(request):
form = SignUpForm()
return render(request,'signup.html')
signup.html:
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<h1>Join Now !!!</h1>
<form action='' method='POST'>
{{ form.as_p }}
<input type='submit'>
</form>
</body>
</html>
答案 0 :(得分:1)
您需要将其传递给模板!
return render(request,'signup.html',{'form': form })
然后在模板中显示它!
{{form.as_p}}