コメントフォームのコメントフィールドにインラインスタイルを追加するつもりはありません。プレースホルダー属性をフィールドに追加する方法を探しています。これを行うための適切な方法は何ですか?
get_comment_create_dataメソッドのウィジェットを追加/変更する方法を探していました。
これが私の現在のフォームの外観です。
# forms.py
...
class PostComment(CommentForm):
"""
A lighter comment form.
"""
def get_comment_create_data(self):
"""
This needs to be overwritten to remove the fields from the class
"""
return dict(
content_type = ContentType.objects.get_for_model(self.target_object),
object_pk = force_unicode(self.target_object._get_pk_val()),
comment = self.cleaned_data['comment'],
submit_date = datetime.datetime.now(),
site_id = settings.SITE_ID,
is_public = True,
is_removed = False,
)
...