Answer the question
In order to leave comments, you need to log in
How to exclude a field from a selection?
The front requests data from the back at the following address:
http://127.0.0.1:8000/users/[email protected]
fields:{fname: "kalinin", lname: "sergey", login: "[email protected]", pass_hash: "D033E22AE348AEB5660FC2140AEC35", created_date: "2018-07-01T10:53:58Z", …}
model:"app_users.user"
pk:1
def get_user(request):
login_ = request.GET['login']
user = User.objects.filter(login=login_)
user_serialized = serializers.serialize('json', user)
return JsonResponse(user_serialized, safe=False)
Answer the question
In order to leave comments, you need to log in
As far as I remember, you can set the fields for serialization:
user_serialized = serializers.serialize('json', user, fields=('fname', 'lname' ...)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question