我的表单输入没有显示。只是个按钮。我想主页.html你没拿到这张表格吗
你知道吗表单.py你知道吗
class NameForm(forms.Form):
your_name = forms.CharField(label='Your name', max_length=100)
你知道吗视图.py你知道吗
def get_name(request):
# if this is a POST request we need to process the form data
if request.method == 'POST':
# create a form instance and populate it with data from the request:
form = NameForm(request.POST)
# check whether it's valid:
if form.is_valid():
# process the data in form.cleaned_data as required
# ...
# redirect to a new URL:
return HttpResponseRedirect('/')
# if a GET (or any other method) we'll create a blank form
else:
form = NameForm()
return render(request, 'mainApp/homepage.html', {'form': form})
你知道吗主页.html你知道吗
{% extends "mainApp/wrapper.html" %}
{% block title %}Главная{% endblock %}
{% block content %}
<h1>Main page</h1>
{% include "mainApp/includes/somehtml.html" %}
<br>
<form action="/account/username/" method="post">
{% csrf_token %}
{{ form }}
<input type="submit" value="Submit" />
</form>
<br>
{% endblock %}
它只使用“提交”按钮。我该怎么修?你知道吗
请换衣服
到
{{form.as_p}}
视图.py
主页.html
相关问题 更多 >
编程相关推荐