Hi, there!

I'm new in DRF and I created a Django project with two apps: one for a REST 
API and one for the frontend. I've created the API and it's working good, 
but now, I'd like to call the API from the frontend app. 

My code:

views.py from api:

class UserViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows users to be viewd or edited.
    """
    queryset = User.objects.all().order_by('-date_joined')
    serializer_class = UserSerializer

views.py from frontend:

def home(request):

    user_view_set = UserViewSet.as_view({'get':'list'})
    response = user_view_set(request)
    users = response.data
    return render(request, 'index.html', {"users":users})

Doing that I can obtain the data, but it's in a strange format. So, I think 
that I'm doing something wrong. I'd like to obtain the JSON response. 

Can someone please help me with that? 

thank you very much!

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to