Questions tagged [drf-queryset]
127 questions
0
votes
1 answer
DRF - queryset filter using contains field lookup on SlugRelatedField
I am struggling to figure out the how to run queryset filter using "field__contains" on a SlugRelatedField.
I have a simple Book model and a Tag model that looks as following:
class Book(models.Model):
title = models.CharField(max_length=100)
…

yudarik
- 113
- 1
- 12
-1
votes
2 answers
How I can use Nested serializer in Django Rest Framework
Hi I'm creating a serializer where I wanna show user profile details and all his products from the product model but it's not working
serializer.py
class UserSerializer(serializers.ModelSerializer):
related_products = ProductSerializer(
…

Mohsin
- 11
- 5
-1
votes
1 answer
QuerySet object has no attribute "email"
I am trying to get a list of all pathologists in my system. I need to filter the user on 2 basis i-e is_pathologist and Lab_Id=request.data[email]
I have tried switching between filter and get but then I…

alish
- 1
- 4
-1
votes
1 answer
AttributeError: 'int' object has no attribute 'pk'
having an issue having 2 foreign keys to the same model, when I post the data I got the eror "AttributeError: 'int' object has no attribute 'pk'" and many more.
Model
class OrderProductsModel(models.Model):
fk_user =…

jhoanmartinez
- 71
- 7
-1
votes
1 answer
DRF (ListAPIView) - how to apply search filter in queryset
I want to fetch the result if the user enters something
Example - if in search box the user enters 'Hello World', then it should only fetch 'Hello World' through DRF ListView.
Views.Py
class FunderViewSet(generics.ListAPIView):
…
user13533843
-1
votes
1 answer
how to iterate over a queryset in django as i get 'int' object is not iterable
I want to get the object from a queryset
accounts = group.get_external_accounts(include_sub_groups=True)
try:
account: StripeExternalAccount = accounts.get(account_id)
except StripeExternalAccount.DoesNotExist:
return…

deve_mo
- 3
- 4
-1
votes
1 answer
Django Path To Resource Failure?
When I try a GET request on one of my API endpoints it can't find the endpoint.
urls.py file looks like this
from django.urls import path, include
from django.contrib import admin
from api.resources import NoteResource
note_resource =…

John Fisher
- 433
- 6
- 13