[英]django {{form.as_p}} results without input widget
So here's my form : 所以这是我的表格:
from django import forms
class PostForm(forms.Form):
name = forms.CharField(),
title = forms.CharField(),
Here's my view : 这是我的看法:
from django.shortcuts import render
from .forms import PostForm
def sign(request):
form = PostForm()
return render(request, 'guestbook/sign_extend.html', {'form': form})
and my html : 和我的html:
{% extends 'guestbook/sign.html' %}
{% block content %}
<form action='.' method ='POST'>{% csrf_token %}
{{ form.as_p }}
<button type="submit">submit</button>
</form>
{% endblock %}
url: 网址:
from django.urls import path,include
from . import views
urlpatterns = [
path('sign/', views.sign,name='sign'),
When I go to the url it only shows me button but no form fields. 当我转到url时,它仅显示按钮,但没有表单字段。 What am I doing wrong here ?
我在这里做错了什么? I can't seem to figure that out..please help
我似乎无法弄清楚..请帮助
you should remove the ,
in the form 您应该删除
,
形式
class PostForm(forms.Form):
name = forms.CharField()
# ^^
title = forms.CharField()
# ^^
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.