You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

generic.py 451B

12345678910111213
  1. class PostActionMixin(object):
  2. """
  3. Simple mixin to forward POST request that contain a key 'action'
  4. onto a method of form "do_{action}". This makes some DetailViews
  5. easier to write.
  6. """
  7. def post(self, request, *args, **kwargs):
  8. if 'action' in self.request.POST:
  9. model = self.get_object()
  10. getattr(self, "do_%s" % self.request.POST['action'].lower())(model)
  11. return self.response