楷模
class VideoInfo(models.Model):
user = models.ForeignKey(User)
video_name = models.CharField(max_length=200)
director = models.CharField(max_length=200)
cameraman = models.CharField(max_length=200)
editor = models.CharField(max_length=200)
reporter = models.CharField(max_length=200)
tag = models.TextField()
形式
class LoginForm(forms.Form):
username = forms.CharField(max_length=50)
password = forms.CharField(widget=PasswordInput())
class VideoInfoForm(forms.Form):
class Meta:
model = VideoInfo
fields = ['video_type', 'director', 'cameraman', 'editor', 'reporter', 'tag']
意见:
class Main(View):
'''Index page of application'''
def get(self, request):
model = VideoInfo
form = VideoInfoForm()
return render_to_response('main.html', {'form':form}, context_instance=RequestContext(request))
调用模板为:
{{form.as_p}}
表格没有出现,但如果我使用LoginForm
它就会出现。我究竟做错了什么?