Created
July 9, 2019 14:29
-
-
Save akshar-raaj/629c70a948a5c7c8f44fc0213f3739b0 to your computer and use it in GitHub Desktop.
DRF Create user
This file contains hidden or 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
| def create_user(request): | |
| user_dict = json.loads(request.body) | |
| # Validate the POSTed data | |
| try: | |
| user = User.objects.create(**user_dict) | |
| except Exception as e: | |
| # Handle exception and gracefully return a proper response | |
| pass | |
| return JsonResponse({'first_name': user.first_name, 'last_name': user.last_name}, safe=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment