Skip to content

Commit 2aeff00

Browse files
committed
add new forms example
1 parent db64fe0 commit 2aeff00

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

content/pages/examples/django/django-forms.markdown

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,4 +611,32 @@ class SetPasswordField(PasswordField):
611611
# source file continues from here with a few more good forms examples
612612
```
613613

614+
## Example 3 from heritagesites
615+
[heritagesites](https://github.com/Michael-Cantley/heritagesites) is a
616+
[Django](/django.html) web application with a [MySQL](/mysql.html)
617+
backend that displays
618+
[UNESCO heritage sites](https://whc.unesco.org/en/list/). The project
619+
code is open source under the
620+
[MIT license](https://github.com/Michael-Cantley/heritagesites/blob/master/LICENSE).
614621

622+
[**heritagesites/heritagesites/forms.py**](https://github.com/Michael-Cantley/heritagesites/blob/master/heritagesites/forms.py)
623+
624+
```python
625+
# forms.py
626+
~~from django import forms
627+
from crispy_forms.helper import FormHelper
628+
from crispy_forms.layout import Submit
629+
from heritagesites.models import HeritageSite
630+
631+
632+
~~class HeritageSiteForm(forms.ModelForm):
633+
~~ class Meta:
634+
~~ model = HeritageSite
635+
~~ fields = '__all__'
636+
637+
~~ def __init__(self, *args, **kwargs):
638+
~~ super().__init__(*args, **kwargs)
639+
~~ self.helper = FormHelper()
640+
~~ self.helper.form_method = 'post'
641+
~~ self.helper.add_input(Submit('submit', 'submit'))
642+
```

0 commit comments

Comments
 (0)