Skip to content

Instantly share code, notes, and snippets.

@unpluggedcoder
Last active September 14, 2017 10:42
Show Gist options
  • Save unpluggedcoder/5fc399988cfd27ae949fc506854e68e3 to your computer and use it in GitHub Desktop.
Save unpluggedcoder/5fc399988cfd27ae949fc506854e68e3 to your computer and use it in GitHub Desktop.
Use corresponding serializer class for different request method in Django Rest Framework - Part 1
# models.py
import uuid
from django.db import models
class Organization(models.Model):
org_uuid = models.UUIDField(
primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=40)
class User(AbstractBaseUser):
user_uuid = models.UUIDField(
primary_key=True, default=uuid.uuid4, editable=False)
# Omit username and all the rest of fields for simplicity.
org = models.ForeignKey('Organization', on_delete=models.CASCADE,)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment