DRF: listview get works, detailview returns empty response
<p>please bear with me. I'm doing something silly but I don't know what. </p>

<p>I'm adapting/following the tutorial for <a href="http://www.django-rest-framework.org/tutorial/1-serialization/" rel="nofollow">Django Rest Framework</a>.</p>

<p>I'm using the serialization part of the tutorial to return users (list and detail views).</p>

<p>my listview (list all users) works perfectly.</p>

<p>my detailview doesn't. I can see that the serializer instance is being populated with a user for the detail view, however serializer.data is empty.</p>

<p>No error are returned, just an empty reply {}.</p>

<p>What am I doing wrong?</p>

<p>this works:</p>

<pre><code>@csrf_exempt
def parentList(request):
    """
    List all parents or create a new parent
    """
    if request.method == 'GET':
        theseParents = PlatformUser.objects.all()
        serializer = parentSerializer(theseParents, many=True)
        return baseJSONResponse(serializer.data)
</code></pre>

<p>snippet from serializer:</p>

<pre><code>class parentSerializer(serializers.ModelSerializer):
    class Meta:
        model = PlatformUser
        fields = ('pk', 'email', 'first_name', 'last_name', 'phone', 'home_address_1', 'home_address_2', 'city', 'country', 'home_postcode', 'photo', 'overview')
</code></pre>

<p>this does not work (<code>serializer.data</code> is empty, but serializer is populated):</p>

<pre><code>def parentDetails(request, pk):
    """
    Retrieve or update a parent record
    """
    try:
        thisParent = PlatformUser.objects.filter(pk=pk)
    except thisParent.DoesNotExist:
        return HttpResponse(status=404)

    if request.method == 'GET':
        serializer=parentSerializer(thisParent)
        return baseJSONResponse(serializer.data)
</code></pre>