GeeWee / django-auto-prefetching

Automatic prefetching for Django
MIT License
231 stars 18 forks source link

function based view support #29

Closed sodrooome closed 3 years ago

sodrooome commented 3 years ago

Hi, i want to ask you something. Related the issue on #18, does this works in function based view? like, using method_decorator or something like that?

GeeWee commented 3 years ago

It depends on how the function view is implemented. All django-auto-prefetching really cares about is getting a queryset and a serializer. The relevant function you call is django_auto_prefetching.prefetch(queryset,self.serializer_class

So in essence: If you use a serializer to render the model, you can use the library, if not - you're out of luck unfortunately.