Discussion:
generic views or viewsets with mixins, which is the better choice?
Sagar Bhadarka
2018-07-19 10:54:05 UTC
Permalink
Hello everyone,
I want to insert user registration data in database and currently I did
that using generic views. But I think that may be viewsets is better
option. I don't have any previous experience with django. so can anyone
explain which is the better choice. And if viewsets is better choice then
should i use mixins?
I have look at documentation and other articles as well. But still I'm
little confused. I'm sure that each of them has their own advantages and
disadvantages. Can anyone explain in which situation what is the better
option?
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jason
2018-07-19 11:04:49 UTC
Permalink
Well, viewsets are an abstraction that take in mixins, as you can see
https://github.com/encode/django-rest-framework/blob/master/rest_framework/viewsets.py#L209-L228.
Generic views themselves are made of the same mixins, as you can see at
https://github.com/encode/django-rest-framework/blob/master/rest_framework/generics.py#L186-L293

basically, use viewsets if you're implementing a highly standard API that
doesn't deviate much from the default implementation features in DRF.
Otherwise, if you need customization and specific things, then implementing
a generic view and overriding would be better. It all depends on your use
case.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...