Check your models
# Create your models here.
from django.db import models
class User(models.Model):
name = models.CharField(max_length=100)
email = models.EmailField()
password = models.CharField(max_length=100)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return self.name
class UserDetail(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
age = models.IntegerField(help_text="Enter Age")
address = models.CharField(max_length=100, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return self.user.name
class UserProfile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
bio = models.TextField()
profile_picture = models.ImageField(upload_to='profiles/', null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return self.user.name
i want Nested Relationships in DRF Serializers