Skip to content

Instantly share code, notes, and snippets.

@kaning
Last active August 29, 2015 14:01
Show Gist options
  • Save kaning/68f294672a3d042dfa1c to your computer and use it in GitHub Desktop.
Save kaning/68f294672a3d042dfa1c to your computer and use it in GitHub Desktop.
class ClassifiedForm(ModelForm):
class Meta:
model = Classified
fields = ['title', 'description', 'contact']
def __init__(self, *args, **kwargs):
super(ClassifiedForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'form-horizontal'
self.helper.form_method = 'post'
self.helper.label_class = 'col-lg-3'
self.helper.field_class = 'col-lg-7 login-fields'
self.helper.add_input(Submit('submit', 'Save Changes', css_class='pull-right'))
self.helper.layout = Layout(
Fieldset(
'Create a classified',
Field('title'),
Field('description'),
Field('contact')
),
Fieldset(
'Describe the classified',
Div(id='meta')
)
)
def save(self, commit=True):
# Do request.POST manipulation here?
super(ClassifiedForm, self).save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment