Last active
February 17, 2018 03:53
-
-
Save safu9/d740770c48dc27eaf755e13fb76f4829 to your computer and use it in GitHub Desktop.
Django FormMixin that can process GET request
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 django.views.generic.edit import FormMixin | |
| # Mixin to process form by GET | |
| class GetFormMixin(FormMixin): | |
| # Override | |
| def get_form_kwargs(self): | |
| """Return the keyword arguments for instantiating the form.""" | |
| kwargs = { | |
| 'initial': self.get_initial(), | |
| 'prefix': self.get_prefix(), | |
| 'data': self.request.GET, | |
| } | |
| return kwargs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment