Questions tagged [drf-queryset]
127 questions
0
votes
1 answer
DRF SearchFilter in ListAPIViews
I'm working on Django==3.2.7, djangorestframework==3.12.4 and django-filter==21.1. and React for the frontend
What I would like to do:
Return Job Offer objects that contains words from search (Search fields job_title and localistation)
Remove…

MOURET Jonas
- 13
- 1
- 5
0
votes
1 answer
Django Rest Framework viewsets.ModelViewSet
I have created a view in my DRF api that takes in a couple of parameters and saves them in the database.Am using a serializer derived from a model to do this.Below is the serializer and model code:
class…

Shangazi Mkubwa
- 45
- 1
- 9
0
votes
0 answers
Customize Create funciton in DRF viewset
I want to customize the user viewset i.e. when the user registers the user account was created as well.
im doing this :
class CustomUserCreate(APIView):
permission_classes = [AllowAny]
def post(self, request):
serializer =…

Rida Syed
- 1
- 1
0
votes
0 answers
Django prefetch m2m through model
I have the following models:
class Block(MPTTModel):
# some fields
links = models.ManyToManyField('self', through='BlockLink', symmetrical=False)
class BlockLink(models.Model):
source = models.ForeignKey(
'Block',…

ddjjaannggoo
- 87
- 8
0
votes
0 answers
'Response' object has no attribute 'user'
I am getting error AttributeError: 'Response' object has no attribute 'user' for the below code I have written
I am trying to get the user info from the context and create a notification model. I am getting the above error while returning the…

Wasim
- 7
- 7
0
votes
1 answer
How can update field by overriding save method which is in another app models
I have two models Bill and Payment each with 3 fields. Here I want to update field last_price directly when user pay bill. If user pay complete amount then it would be 0. or if user not pay complete amount then remaining amount want to be save in…

Shweta Shinde
- 95
- 11
0
votes
0 answers
Way to get custom queryset along with serialized relation response in django-rest-framework
Currently I'm implementing the django-rest-framework in my project. I want a custom response from my serializer (which is a serialized relation) but at the same time I also want to use custom queryset with query params so I implemented…
0
votes
1 answer
DRF ViewSet - dealing with query params
I want to change a queryset in my ViewSet depending on query parameters.
I see that there is a list of tags in query params, but when I try extract them I get just last tag as a string. And I have no idea why and how it should work. Can someone…

Константин
- 39
- 6
0
votes
2 answers
How to filter Django REST Framework queryset by foreign key of nested object?
I have the following Django models:
class Pa(models.Model):
pa_name = models.CharField
class Pb(models.Model):
pa = models.ForeignKey(Pa, related_name="pbs")
pb_name = models.CharField()
class Pc(models.Model):
pb =…

TMOTTM
- 3,286
- 6
- 32
- 63
0
votes
1 answer
Best way to serialize object dynamically based on parameter using Django Rest Framework
I want to render a dynamically selected object using an intermediate model and a custom query_param.
For instance,I want to make a query like this:
http://api.url/v1/recipes/19/?location=1 and obtain a serialized Recipe object with it's ingredients…

Wood Pecker
- 75
- 5
0
votes
1 answer
difference between django.shortcuts and rest_framework.generics
what is difference between two The following sentence
from django.shortcuts import get_object_or_404
and
from rest_framework.generics import get_object_or_404

Ali Rahmani
- 37
- 1
- 7
0
votes
1 answer
Return different ManyToMany objects based on param using Django and DRF
I'm trying to figure out if what's the best way to implement this behavior:
I have an object of type "Recipe", whose related model "IngredientRecipe" is obtained from a list of "Products" with information about its "Supplier". A recipe may have…

Wood Pecker
- 75
- 5
0
votes
1 answer
How to get data that belongs to specific user in Django Rest Framework?
I haved Format_List model with relation with Django user and now I want to get the data belongs to specific user by giving user id or after user login.
models.py
class Format_List(models.Model):
class Meta:
db_table =…

Manas Ranjan Pati
- 31
- 6
0
votes
0 answers
Why my data of drf is being removed in heroku?
I have a Django Rest framework app in Heroku. The model objects and users I create from the admin panel automatically get removed after some time. I am using the django's dbSqlite3 as my database.
Why my data is not being stored in Heroku?? Is there…

Deepu
- 31
- 1
- 5
0
votes
2 answers
DRF Custom Pagination not working properly
Recently I was working with drf pagination class,PageNumberPagination.I may or may not have encountered a weird bug .
The official docs mention,to overide the page size of PageNumberPagination we have to create a Custom paginator which overides the…

Kunal Solanke
- 48
- 1
- 7