def stuser_detail(request, username):
    """
    Retrieve, update or delete a code snippet.
    """
    try:
        stuser = STUser.objects.get(username=username)
    except STUser.DoesNotExist:
        return HttpResponse(status=404)

    if request.method == 'GET':
        serializer = STUserSerializer(stuser)
        return JSONResponse(serializer.data)

    elif request.method == 'PUT':
        data = JSONParser().parse(request)
        serializer = STUserSerializer(stuser, data=data)
        if serializer.is_valid():
            serializer.save()
            return JSONResponse(serializer.data)
        else:
            return JSONResponse(serializer.errors, status=400)

    elif request.method == 'DELETE':
        stuser.delete()
        return HttpResponse(status=204)
def stuser_list(request):
    """
    List all code snippets, or create a new snippet.
    """
    if request.method == 'GET':
        stusers = STUser.objects.all()
        serializer = STUserSerializer(stusers, many=True)
        return JSONResponse(serializer.data)

    elif request.method == 'POST':
        data = JSONParser().parse(request)
        serializer = STUserSerializer(data=data)
        if serializer.is_valid():
            serializer.save()
            return JSONResponse(serializer.data, status=201)
        else:
            return JSONResponse(serializer.errors, status=400)