Created
May 16, 2017 00:43
-
-
Save KTruong008/f333e57c49b8d4b16adbef513c003efb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HandList(generics.ListCreateAPIView): | |
serializer_class = HandSerializer | |
def get_queryset(self): | |
return Hand.objects.all().filter(user__username=self.request.user) | |
def perform_create(self, serializer): | |
print (‘hit perform_create’) | |
deck = None | |
try: | |
print(‘hit the try guys’) | |
deck = Deck.objects.get(pk=self.request.data.get(‘deck’, {}).get(‘id’, None)) | |
except Deck.DoesNotExist: | |
print(‘deck does not exist’) | |
pass | |
if deck: | |
print(‘jackpot’) | |
serializer.save( | |
user=self.request.user, | |
deck=deck | |
) | |
else: | |
print(‘fail’) | |
serializer.save(user=self.request.user) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment