0
问题是,first_name,last_name和email字段不显示在浏览器中。命令提示符显示没有错误,并且服务器运行正常。 我找不出什么的problem.Here是我code.I正在使用Django 1.11和Python 3.6模型形式fiels不显示在django的视图中
models.py
from django.db import models
# Create your models here.
class signup(models.Model):
first_name=models.CharField(max_length=120,null=True,blank=True)
last_name=models.CharField(max_length=120,null=True,blank=True)
email=models.EmailField()
timestamp=models.DateTimeField(auto_now_add=True,auto_now=False)
updated=models.DateTimeField(auto_now_add=False,auto_now=True)
def __str__(self):
return self.email
forms.py
from django import forms
from .models import signup
class sign_up_form(forms.ModelForm):
class Meta:
model = signup
fields='__all__'
views.py
from django.shortcuts import render,render_to_response
from django.template import RequestContext
from .forms import sign_up_form
# Create your views here.
def home(request):
form = sign_up_form()
return render(request,'signup.html',)
signup.html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>join now</h1>
<form method="POST" action="">{% csrf_token %}
{{ form.as_p }}
<input type="submit">
</form>
</body>
</html>
谢谢!!它工作顺利。 – Panther