Reputation: 9061
I'm not looking to add inline styles to the comment field in my comment form. I'm looking for a way to add the placeholder attribute to my field. What's the proper way to do this?
I was searching for a way to add/modify the widgets for the get_comment_create_data method.
This is how my current form looks:
# 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,
)
...
Upvotes: 0
Views: 171
Reputation: 22449
You can extend a class method like this:
class PostComment(CommentForm):
def get_comment_create_date(self):
data = super(PostComment, self).get_comment_create_data()
data.update(dict(
placeholder = 'foo'
))
return data
Upvotes: 1