Questions tagged [django-rest-viewsets]

362 questions
0
votes
1 answer

Django Rest Framework Serializer not printing nested relationship

I've got established a relationship between 2 models: Order and OrderLine. I've created serializers for both of them following the DRF documentation, yet when printing the serializer.data the nested objects don't show. Here are my models: class…
0
votes
2 answers

Is there a way to return multiple json objects through django rest api?

I know, I can return a single object through Django viewsets for any method. But can I return multiple objects through the API? I have something like this: class SomeViewSet(viewsets.ModelViewset): queryset = SomeModel.objects.all() …
Anjaan
  • 595
  • 5
  • 19
0
votes
1 answer

How to use lookup_field along with FilterSet in Django Rest Framework?

I am working on developing an API for a project and it contains a course list page where All the courses offered by a particular college is listed. Should support retrieving of a specific course using lookup_field as course_slug. Supports filtering…
0
votes
1 answer

Django rest framework global permission not working with custom permission at Viewset

This is my global configuration of Default permission classes which has been configured to use IsAuthenticated permission. REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ['rest_framework.authentication.SessionAuthentication', …
0
votes
0 answers

How to take output with return input json response in django rest framework api

I Want to return output with JSON response when API call with inputs in DJANGO REST FRAMEWORK, I want output_table_name with DJANGO REST FRAMEWORK API response, Can anyone please help me This is my models.py:- class postgis_KNN(models.Model): …
0
votes
2 answers

Unable to fetch parameters from Django URL

I am using Django REST Framework and I want to fetch the two parameters entered in the URL. My URL is: http://127.0.0.1:8000/api/v1/colleges/slug2/courses/sug1/ where 'slug2' and 'sug1' are the two slug parameters entered. I want to retrieve those…
0
votes
1 answer

Send related image to Django Rest Framework

Hello everyone reading this post. I got such issue. So, first of all I have such models layout class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile') description =…
0
votes
1 answer

Create generic viewset and serializer for models in django rest framework

I am making a lot of views and serializers for my models that takes all fields. They all look like this: class MyModelViewSet(viewset.ModelViewSet): queryset = MyModel.objects.all() serializer_class = MyModelSerializer class…
0
votes
1 answer

How to handle datetimes for users in different locations django?

I have an application that is being built with Django and Django REST Framework. Users can add certain objects to the database and set expiry dates on them. Other users will retrieve those added items from the database and it will be displayed…
0
votes
1 answer

Using multiple admin.py files for Django rest?

I currently have 2 admin.py files. project/admin.py project/pages/basicpage/admin.py I would like to use the registered classes inside the second admin.py along with the first admin.py such that they can both be reached at the same admin…
0
votes
1 answer

DRF -django rest framework APi multiple file upload through API

I am trying to upload multi-images to a single post which currently I am being able to upload only single image and get the confirmation through API. How can I make this to multi upload ? My models.py from django.db import models # Create your…
Mitesh
  • 1,544
  • 3
  • 13
  • 26
0
votes
1 answer

I'm getting 'module' object is not callable in Django Rest Framework

I'm trying to learn django rest framework for an api. I'm following the documentation and checked all the imports but I'm getting the typeerror: 'module' object is not callable Views.py from rest_framework import viewsets from .serializer import…
0
votes
1 answer

nIs possible group nested objects from the same queryset?

I have a Viewset that looks like this: class EstadisticasEquipoViewSet(viewsets.ModelViewSet): """ Trae estadísticas totales de todos los equipos de una zona en una respectiva liga. """ serializer_class = EstadisticaEquiposSerializer def…
0
votes
1 answer

DRF serialize through related models data

I've got a problem with DRF serialization. My main goal is to create an instance which has a related field but instead of providing the related models id i want to use it's other unique field. At the same time when I will serialize my model to…
0
votes
0 answers

Django rest_framework / validate PATCH request

I'm new in Django Rest framework. I'm trying to do some test task (simple RestAPI service) but it failed. I've created model Order, serializer OrderSerializer(HyperlinkedModelSerializer), and OrderViewSet(ModelViewSet). (nothing special, use code…