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