You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
django/comments/forms.py

17 lines
494 B

# 模块说明:评论表单定义,支持提交正文与可选的父评论 ID。
from django import forms
from django.forms import ModelForm
from .models import Comment
class CommentForm(ModelForm):
"""评论提交表单:包含正文与隐藏的父评论 ID"""
parent_comment_id = forms.IntegerField(
widget=forms.HiddenInput, required=False)
class Meta:
"""绑定模型与字段,仅开放 body 字段"""
model = Comment
fields = ['body']