Questions tagged [drf-queryset]
127 questions
0
votes
3 answers
controling two tables in views
I'm new in django rest framework and i faced this problem
I have two tables Order,Payment I want to get all orders that didn't have payment in the view how can i do this
Models
class Payment(models.Model):
created_at =…

Adnan
- 23
- 4
0
votes
1 answer
how to perform django queryset in more efficient way to get following response?
here is my model fields:
staff = models.ForeignKey(StaffProfile, on_delete = models.SET_NULL, blank=True,null = True)
created_at = models.DateTimeField(auto_now_add=True)
category = models.CharField(max_length = 250,choices =…
0
votes
1 answer
Serializing Array Field to String
I have an array field in my model i need to serialize and return the first 10 tags from the query getting error while serialising the data.
referred - DRF serialize ArrayField as string
serializers.py
class StringArrayField(ListField):
"""
…

jimmy
- 45
- 9
0
votes
1 answer
unable to specify the fields in drf queryset using drf-yasg
class ABC(generics.ListCreateApiView):
@swagger_auto_schema(
operation_description="THIS API IS TO CREATE MESSAGES IN A LIST ",
auto_schema=AcceptFormDataSchema,
request_body=MessageGetSerializer
…

ast
- 1
0
votes
2 answers
Django Queryset filter
My django table contains a field that contains comma-separated strings.
class RawData(TimeStampModelMixin):
id = models.UUIDField(primary_key=True)
media = models.TextField()
media column will hold values like 'Multimedia, TV',…

Saiful Islam
- 139
- 5
- 16
0
votes
0 answers
DRF SlugRelatedField causes extra queries with the argument `queryset` when making get request
in debug tool bar, I can tell there are duplicate queries pointing to source and target and also workflow, which are foreign keys of my model Flow. And in the serializer I use SlugRelatedField for creation with the argument queryset.
So I decide to…

Randix Lai Randy
- 83
- 1
- 8
0
votes
1 answer
custom pagination of limit and page in Django Rest Framework
I wanted to create custom paginations for this get_queryset.
get_queryset = Comments.objects.filter(language_post_id=post_in_lang_id,is_post_comment=True).order_by('-created_on')[offset:offset+limit]
I want to change the offset value whenever the…

MdHassan413
- 63
- 9
0
votes
1 answer
return response number of count in django rest framework
I wanted to return the response number of the count of chiled_comments as in blew table.
like for id no. 3 have 2(count) "parent_post_comment_id".
and same as id no. 1 have only 1(count)…

MdHassan413
- 63
- 9
0
votes
1 answer
drf: serializers.ModelField > How can i get user_id appropriately?
I want to implement the 'user_id' to be automatically saved at the backend without receiving it from the client. (when create object!)
This is my code.
models.py
class User(AbstractUser):
username = None
email =…

Jia Kwon
- 11
- 5
0
votes
1 answer
ModelViewSet Queryset Filter with table based value with another table
I have two tables in my database ProductStock and Sales.And I am storing the Product info in the ProductStock table and Sales info inside the Sales table.
Based on the total sum of sold quantity I want to filter the data, and return the data only…

mufazmi
- 1,103
- 4
- 18
- 37
0
votes
1 answer
Object of type Email is not JSON serializable, How to create or update Django model object
I'm trying to build an object from my Email model, if the 'user_email' which is a user_email = models.CharField(primary_key=True, max_length=200) already exists just update it, if it doesn't exist create a new one I show you how I create my new…

laur
- 500
- 1
- 9
- 23
0
votes
1 answer
Django Rest Framework not showing updated field until server restart
I am using DFR. when I send patch request for updating Patient record it changes in database and I can see it in admin panel, yet the response api request doesn't change until I restart the server.
Patient Model:
class Patient(models.Model):
user =…

Ehsan Fouladi
- 11
- 1
0
votes
1 answer
Direct assignment to the reverse side of a related set is prohibited. Use images.set() instead while using create()
I am building a simple images blog app, And I build two models and one with Parent ForeignKey.
I made the serializer but when I try to create a new instance then it is keep showing me
Direct assignment to the reverse side of a related set is…

MyPan
- 3
- 3
0
votes
1 answer
Want to send extra data from BasePermission to Queryset in ModelVIewSet DRF
Here is My Seller Model which has User as OneToOneField
#models.py
.
.
class CompanyProfile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="user")
company = models.CharField(max_length=255)
…

Gulshan Prajapati
- 584
- 4
- 11
0
votes
1 answer
Show particular records at the bottom in webpage
I have drf website where i am showing the records of some sought on my website i have 4 different type of statuses on my webpage for records how do i show a particular status records related to the records at the bottom.
class MyListView(APIView):

Dexter
- 1
- 1