Skip to content

Instantly share code, notes, and snippets.

@safu9
Last active February 17, 2018 03:53
Show Gist options
  • Select an option

  • Save safu9/d740770c48dc27eaf755e13fb76f4829 to your computer and use it in GitHub Desktop.

Select an option

Save safu9/d740770c48dc27eaf755e13fb76f4829 to your computer and use it in GitHub Desktop.
Django FormMixin that can process GET request
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