Django Rest Framework redirects to GET after a failed POST -
i'm trying post django rest framework api view page. server running on localhost, , debug=true. 500 error, redirects same page, providing me no helpful error debugging information.
[16/jan/2016 19:07:00] "post /account/create/ http/1.1" 500 12031 [16/jan/2016 19:07:00] "get /account/create/ http/1.1" 405 4810
so instead of getting helpful information fixing 500 error, page saying "method not allowed." anyway fix this?
here's code:
class createaccount(apiview): def post(self, request, format=none): serializer = registrationserializer(data=request.data) if serializer.is_valid(): try: print account.objects.get(username="reparadocs") account = account.objects.get(username=serializer.data['username']) except objectdoesnotexist: account = account.objects.create_user( serializer.data['username'], '', serializer.data['password'] ) token = token.objects.create(user=account) return response({'token': token[0].key}, status=status.http_201_created) return response({'errors': 'username exists'}, status=status.http_400_bad_request) return response(serializer.errors, status=status.http_400_bad_request)
Comments
Post a Comment