Hello All,
DRF failing to pull the data from User model
I have two Serializers for Two models(User model and UserProfile). 
models.py----------class UserProfile(models.Model):
    Photo = models.FileField(upload_to='documents/%Y/%m/%d/', null=True)
    uploaded_at = models.DateTimeField(auto_now_add=True, null=True)
    dob = models.DateField(max_length=20, null=True)
    country = models.CharField(max_length=100, null=True)
    State = models.CharField(max_length=100, null=True)
    District = models.CharField(max_length=100, null=True)
    phone = models.CharField(max_length=10, null=True)

    def __str__(self):
        return self.phoneserializers.py-----------------from rest_framework 
import serializers
from django.contrib.auth.models import User
from .models import UserProfile


class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ('first_name', 'last_name', 'email')


class ProfileSerializer(serializers.ModelSerializer):
    class Meta:
        model = UserProfile
        fields = ('Photo', 'dob', 'country', 'State', 'District', 'phone')
views.py------------
class getUserProfile(generics.ListAPIView):
    lookup_field = []
    def get(self, *args, **kwargs):
        qs = User.objects.all()
        qs1 = UserProfile.objects.all()
        UserData = UserSerializer(qs).data
        ProfileData = ProfileSerializer(qs1).data
        return Response({'UserData': UserData, 'ProfileData': ProfileData})


If you one see the above screenshot, it clearly says that "UserData" serializer 
doesn't getting any data, as well as the ProfileData is successfully pulling 
the column names, however, the values are NULL. Below screenshot show that 
there are data in the table
UserData

ProfileData

Please suggest.


Regards,
Amitesh

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/979964516.653709.1587998763254%40mail.yahoo.com.

Reply via email to