我在forms.py中将自定义注释表单定义为fallow
class CommentFormWithReply(CommentForm):
reply_to = forms.ModelChoiceField(queryset=CommentWithReply.objects.all(),
widget=forms.HiddenInput(), required=False)
def get_comment_model(self):
# Use our custom comment model instead of the built-in one.
return CommentWithReply
def get_comment_create_data(self):
# Use the data of the superclass, and add in the title field
data = super(CommentFormWithReply, self).get_comment_create_data()
return data
如何使用当前用户信息作为默认值(名称,电子邮件,网页)呈现此表单 .
1 回答
可能是这样的:
https://docs.djangoproject.com/en/dev/ref/forms/fields/#initial