Skip to content

Instantly share code, notes, and snippets.

@rafaelcanovas
Last active March 2, 2021 17:04
Show Gist options
  • Select an option

  • Save rafaelcanovas/6116630 to your computer and use it in GitHub Desktop.

Select an option

Save rafaelcanovas/6116630 to your computer and use it in GitHub Desktop.

Revisions

  1. rafaelcanovas revised this gist Mar 7, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion forms.py
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    from django import forms

    class MyForm(forms.Form):
    class HTML5Form(forms.Form):
    def __init__(self, *args, **kwargs):
    super(MyForm, self).__init__(*args, **kwargs)

  2. rafaelcanovas created this gist Jul 30, 2013.
    9 changes: 9 additions & 0 deletions forms.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    from django import forms

    class MyForm(forms.Form):
    def __init__(self, *args, **kwargs):
    super(MyForm, self).__init__(*args, **kwargs)

    for _, field in self.fields.items():
    if field.widget.is_required:
    field.widget.attrs['required'] = 'required'