Questions tagged [django-rest-viewsets]
362 questions
0
votes
1 answer
Django blogs using Rest framework connecting mutliple images to that content in single object
Is there anyway where we can build logic Using django rest framework
where user can add blog with multiple images and content accordingly and when saved
and retrieved it should be able to display the same kind of UI depening up on the frontend…

John
- 137
- 2
- 12
0
votes
0 answers
DRF additional action without suffix
I am trying to use Django Rest Framework to perform an additional action from a viewset. In the urls I have:
router = SimpleRouter()
router.register(r'mymodels', MyModelViewSet, basename='mymodel')
urlpatterns = [
url(r'',…

gonczor
- 3,994
- 1
- 21
- 46
0
votes
1 answer
How to get the data including the relation table's entry with a GET request in DRF
I'm trying my hand at DRF recently and I've got this issue below to be solved for my project.
I've two Models
class JobsMaster(models.Model):
job_id = models.CharField(max_length=128, unique=True)
job_name = models.CharField(max_length=128)
…

vvk24
- 470
- 5
- 18
0
votes
1 answer
Select one to many relation table in query set django
I would like to select one to many table relation in query set.I have two model.
class Post(models.Model):
postid = models.AutoField(primary_key=True)
class Meta:
db_table = 'post'
class Images(models.Model):
postid =…

Loran
- 772
- 4
- 16
- 38
0
votes
0 answers
Raw SQL to Django ORM queryset conversion
Here I have a queryset where I am using raw SQL to get data.
But this approach is not fulfilling my requirements.
I want to convert this query into pure Django ORM query
queryset = Model.objects.raw("select id,category,count(category)
as…

Iceman
- 157
- 1
- 9
0
votes
2 answers
ERROR: Cannot create a Meal instance with a FK Store instance in the views.py (Django and Django Rest Framework)
I am doing a delivery API REST usign Django and Django Rest Framework.
In the Meal app there is an ERROR that has been for days and I cannot solve it. I do not know how to fix it.
Thanks you in advance.
This is the bug shown in postman:
{
…

xavier
- 57
- 2
- 8
0
votes
2 answers
Error in base_name argument in register() in Django Rest Framework
I'm working in Django Rest Framework.And I have defined a view set in the views.py file like this:
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from rest_framework import…
user13266902
0
votes
2 answers
Validation in case of multiple objects serializer
My data input is in the form of list of 'n' number of dicts
"contact_person":[
{
"contactperson_salutation[0]":"sddd",
"contactperson_first_name[0]":"santoorr",
…

beginners
- 305
- 3
- 16
0
votes
1 answer
Change standard endpoints urls Django Rest Framewrok
I'm using viewsets.ModelViewSet and want to replace the standard endpoints URLs
for example:
instead of creating new snippet with the "standard" endpoint
POST {BAST_URL}/snippet/
I want to replace it with "create" URL and disabling the standard
POST…

Yocheved Z
- 25
- 4
0
votes
1 answer
django-rest-framework: Can Ihave multiple templates per ViewSet?
I've created a serializer and ViewSet for my model and added a template for a list view. To get to see the web page (template) the ordering render classes must be correct and one needs to add the TemplateHTMLRenderer to the list of renderers.
This…

beginner_
- 7,230
- 18
- 70
- 127
0
votes
1 answer
DRF get only the first serialized instance for list view?
I'm working on a real estate app and want the listings to show only the first image of the Listing. Currently it is showing all images.
class Image(models.Model):
photo = models.ImageField(blank=True, upload_to=get_image_filename)
listing =…

master_j02
- 377
- 3
- 13
0
votes
0 answers
DRF adding images to a ForeignKey already in the database
I am looking to add Images, to a Listing(ForeignKey), which will already be in my database.
I have an Image model..
class Image(models.Model):
photo = models.ImageField(blank=True, upload_to=get_image_filename)
listing =…

master_j02
- 377
- 3
- 13
0
votes
1 answer
How to paginate a returned list from viewset in DRF?
In reference to the question asked earlier :
Similar Question related to the pagination
I am still not getting the Metadata(Count,previous and next) in the response.
class LinkHeaderPagination(pagination.PageNumberPagination):
…

Shubham Kumar
- 105
- 1
- 1
- 8
0
votes
1 answer
How to add metadata(count,next,previous) to Response sent through viewset in Django rest framework
views.py
def list(self, request, *args, **kwargs):
queryset= User.objects.all().values_list('name','designation')
queryset=[{'name':i[0],'designation':i[1]} for i in queryset]
…

Shubham Kumar
- 105
- 1
- 1
- 8
0
votes
0 answers
Django: Lookup User OnetoOne Field using username with Model View Sets (Django Rest API)
My task is for an administrator in my application to be able to create and update an employee's details. Given that django's user model simplifies authentication, I used it as a OnetoOneField in my Employee Model, representing the key as the…