Django Python
Using get method to return a single column with instance of the fields.
The
get_object
method returns queryset
i.e list of records, instead of instance
.To get instance
you can use first()
on filter()
. This will gives you first occurrence.def get_object(self, queryset=None):
obj = Staff.objects.filter(pk=self.kwargs['staff_id']).first()
return obj
Comments
Post a Comment