Skip to content

Instantly share code, notes, and snippets.

@gileno
Created January 16, 2015 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gileno/ce32baa8865b901575e1 to your computer and use it in GitHub Desktop.
Save gileno/ce32baa8865b901575e1 to your computer and use it in GitHub Desktop.
Alterando atributos do widget no Form
from django import forms
class MeuForm(forms.Form):
campo1 = forms.CharField(label="Campo 1")
def __init__(self, *args, **kwargs):
super(MeuForm, self).__init__(*args, **kwargs)
self.fields["campo1"].widget.attrs["class"] = "classe_css1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment