This is a humble request, for beginners who are relatively new to Django 
(or GenericView), after reading the official Generic Editing Views 
<https://docs.djangoproject.com/en/dev/ref/class-based-views/generic-editing>, 
it doesn't mention a word about how to override the get/post/update method, 
which I believe in real world project, developers need to do that usually, 
for example: 

   - When GET a resource, I want to do a counting job to record total hit 
   on this specific resource
   - When a posted form is invalid, I want to perform some customised works 
   other than just display error message on the client
   - When POST a resource, I want to invoke my back-end  message server do 
   do a async task
   - When PUT/PATCH a resource, I want to invoke a remote REST API to 
   update a remote resource as well
   
So IMHO it would be better if the official documentation: Generic Editing 
Views 
<https://docs.djangoproject.com/en/dev/ref/class-based-views/generic-editing> 
can 
explain how to achieve that like following:

==============================
class CreateView(generic.CreateView):
    model = MyModel
    form_class = MyModelForm
    object = None

    def post(self, request, *args, **kwargs):
        form_class = self.get_form_class()
        form = self.get_form(form_class)

        if form.is_valid():
            # Do my customised works
            return redirect(reverse("my_app:index"))
        else:
            return self.form_invalid(form)
==============================

I am very open to discussion and listen any different opinions regarding 
above, if some fellow developers agree with me, I will submit a ticket and 
pull request as well, thank you!

Sincerely yours,
Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/58723e2c-b205-4164-ae5c-7c7e58b28aea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to