Questions tagged [django-rest-viewsets]
362 questions
0
votes
0 answers
Make Django REST to call create method of first class from retrieve method of another class
Below code calls the retrieve method and works fine
class SomeWorkflow(ViewSet):
serializer_class = SomeWorkflowSerializer
def retrieve(self, request, pk):
response = OtherWorkflow.as_view({'get': 'retrieve'})(request._request,…

Akshay Sharma
- 23
- 7
0
votes
2 answers
Django rest API, nested serializer add/edit multiple real estate images to one listing?
I am pretty stuck working with DRF for the first time. I am looking to upload multiple Images to a single real estate Listing.
My image model
class Image(models.Model):
photo = models.ImageField(blank=True, upload_to=get_image_filename)
…

master_j02
- 377
- 3
- 13
0
votes
1 answer
How to upload image in user profile model while has one to one relationship with user model in django rest framework?
I have a UserProfile model which has one to one relationship with User model.
I am facing problem in uploading image by rest-framework API endpoint to nested model.
Problem is: Though I am explicitly using @action() decorator, then also it is…

Pran Kumar Sarkar
- 953
- 12
- 26
0
votes
2 answers
django post api through postman
**Hi when I try to hit the post api from postman I am receiving the response from API but the request is not received from postman
when I print the request it showing but not the data
and i attached the screenshot of postman
**
from…

Abishek
- 47
- 1
- 1
- 7
0
votes
1 answer
Secure a file in endpoint with the same permissions as the endpoint in Django REST
I have a project in Django REST framework with model like this
class Attachment
attachment_type = models.PositiveSmallIntegerField(choices=constants.AttachmentTypes.CHOICES)
creator = models.ForeignKey(User, related_name="attachments",…

Rob
- 41
- 5
0
votes
1 answer
With drf-yasg, how to use statics schemas and manage custom permissions?
I am a little confused how to develop the documentation using the drf-yasg library. So I would like to ask exactly:
How can I use a static swagger.json file created by swagger editor online with drf-yasg?
(There are endpoints in my project that…

vic.py
- 409
- 10
- 22
0
votes
3 answers
creating custom or modified url using router for retrive method of ModelViewSet
I want to create a custom or modified url using router for ModelViewSet.
Current scenario:
/models.py
class BlogPost(models.Model):
title = models.CharField(max_length=300)
description = models.TextField()
slug =…

Rajesh Samui
- 167
- 1
- 2
- 12
0
votes
1 answer
Error creating merged queries with Q() and filter() in a viewset with djangoORM
I am trying to create a filter with multiple elements in a queryset for a MOdelViewSet. I am overwriting the get_queryset method to fetch the results according to a user role.
I am using Q() and works perfectly when i try to a single filter, for…

Omar España
- 125
- 6
0
votes
1 answer
Django, Custom action functions in GenericViewSet or Viewset
I am trying to implement a basic messaging system.
User can get unread/read/sent messages. Each of these routes also returns a different serialized jsons. So I do not have one serializer for the whole ViewSet.
To do this I tried to implement…

Evren Bingøl
- 1,306
- 1
- 20
- 32
0
votes
1 answer
Django-rest :send POST request with 2 foreign key
I want to post a data in a serializer, having 2 ForeignKey.
I have these models:
class Child(models.Model):
first_name = models.CharField(max_length=40)
description = models.CharField(max_length=40)
class Parent(models.Model):
name =…

Wave1988
- 57
- 6
0
votes
1 answer
"How to Add "Nested URL in DRF ,dynamic model viewset"
* i have * router.register(r'reseller/', views.UserViewSet)
and router.register(r'one/', views.OneLViewSet)
I want to make nested url like 'reseller/ or {pk}/one/
But i'm failed.
I tried adding DynamicRelationField to User Model but not…

Ďröîd Čŕäžÿ
- 35
- 1
- 7
0
votes
0 answers
Django API: How to save/ save as project?
I am developing python backend for django web app.
In the application when user clicks on Save or Save As button then I should give pop up for confirmation which can be handled by frontend.
But in back end, when user opts to save the progress then I…

oldy kayaks
- 1
- 1
0
votes
3 answers
Django Rest Framework: Get singular object using the root API
I am trying to set up an API endpoint that returns a singular object.
Right now I have:
class ShoppingCartViewSet(viewsets.GenericViewSet, mixins.ListModelMixin):
"""
API endpoint that allows users to be viewed or edited.
"""
…

Kenny Ye
- 587
- 1
- 5
- 12
0
votes
1 answer
django-rest-framework: Adding bulk operation in a ModelViewSet
I have many endpoints which use ModelViewSet to manage CRUD operations for my models.
What I am trying to do, is to add bulk create, update, and delete at these same endpoints. In other words, I want to add POST, PUT, PATCH and DELETE to the…

MarkD
- 4,864
- 5
- 36
- 67
0
votes
1 answer
how to chain queryset mixin for django rest viewsets?
I need to write the following querysets mixins:
class VendorOwnedQuerySetMixin(models.QuerySet):
def get_objects_for_vendor(self, request):
vendor_user = VendorUserModel.objects.get(user=request.user)
return…

Kim Stacks
- 10,202
- 35
- 151
- 282