Created
January 20, 2017 14:44
-
-
Save timonweb/9459beedd98604d05e000cb129b75ef9 to your computer and use it in GitHub Desktop.
Add attributes to form fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contact_form.forms import ContactForm | |
# My form is a child of ContactForm class provided by django_contact_form module | |
class MyContactForm(ContactForm): | |
def __init__(self, data=None, files=None, request=None, | |
recipient_list=None, *args, **kwargs): | |
super().__init__(data=data, files=files, request=request, recipient_list=recipient_list, | |
*args, **kwargs) | |
self.fields['name'].widget.attrs['placeholder'] = 'name' | |
self.fields['email'].widget.attrs['placeholder'] = 'e-mail' | |
self.fields['body'].widget.attrs['placeholder'] = 'message' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment