From 97351a6831bc2ef1ba05d0322728db7ef81b1d46 Mon Sep 17 00:00:00 2001 From: Juan Sebastian Moreno Hernandez Date: Sun, 27 Jun 2021 23:11:10 -0500 Subject: [PATCH] FIX: Dependency bug https://github.com/django-json-api/django-rest-framework-json-api/issues/325 --- apps/finances/views/credit_cards.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/finances/views/credit_cards.py b/apps/finances/views/credit_cards.py index 7f850ce..27d4bd4 100644 --- a/apps/finances/views/credit_cards.py +++ b/apps/finances/views/credit_cards.py @@ -20,17 +20,22 @@ class CreditCardViewSet( ): """ Credit card query views set""" - serializer_class = CreditCardModelSerializer + def get_serializer_class(self): + import ipdb + + ipdb.set_trace() + try: + self.request.user + except: + pass + if self.request.user.is_superuser: + return CreditCardSuperUserModelSerializer + return CreditCardModelSerializer def get_queryset(self): if self.request.user.is_superuser: return CreditCard.objects.all() return CreditCard.objects.filter(user=self.request.user) - def get_serializer_class(self): - if self.request.user.is_superuser: - return CreditCardSuperUserModelSerializer - return CreditCardModelSerializer - def perform_create(self, serializer): serializer.save(user=self.request.user) \ No newline at end of file