Questions tagged [django-rest-viewsets]
362 questions
1
vote
1 answer
Django Rest Framework validate method not working
This is my first task that I'm doing in Rest Framework.I referred a video tutorial to do this and it's weird why my validate method in serializer not working even if I totally copied the code from the video.
Below is my view function:
class…

user10058776
- 183
- 1
- 3
- 17
1
vote
2 answers
Emailing when a instance is created or updated using Django
Intro: I have 2 Django Rest Framework models Patient and Embryo There is only 1 user who is the superuser. All the patients belong to the superuser. A patient can have many ebryo's but each embryo can have only 1 patient.
What I want to do: I am…

Samir Tendulkar
- 1,151
- 3
- 19
- 47
1
vote
1 answer
How to make Django Rest API fore nested comments?
I want to make a nested comment model for an android app and I am using Django Rest framework. I have defined two models Post and Comment as follow:
class Post(models.Model):
title = models.CharField(max_length=100)
description =…

hardik24
- 1,008
- 1
- 11
- 34
1
vote
1 answer
Django Rest Framework can't register route
I have the following code:
# urls.py
from django.contrib import admin
from django.urls import include, path
from rest_framework import routers
from api import views
router = routers.DefaultRouter()
router.register(r'mymodel', views.MyModelViewSet,…

yierstem
- 1,933
- 5
- 21
- 42
1
vote
0 answers
DRF+Ajax Method "POST" not allowed. viewsets + router
I am getting error 'Method "POST" not allowed' while running the api. I have use ModelViewSet and Routers
Also use Ajax on front-end to send "POST"-request.
I did GET and PUT, and it's work perfectly, but POST - never.
in app.views.py
class…

Николай Погорелый
- 11
- 2
1
vote
1 answer
How to use filter in serializers using django rest framework
We need help
How do I achieve the following...
Here, I have two models example1 and example2 in that I already joined two table using serializers now I want to filter using fields (patient_n_key,centre_master_short_name) either in example2serializer…

Micheal
- 21
- 1
- 8
1
vote
1 answer
django rest framework "ModuleNotFoundError: No module named 'router'"
i have imported all the restframework packages but i don't understand why am i getting this strange error
from django.conf.urls import *
from django.contrib import admin
from django.views.generic.base import TemplateView
from .views import…
user7671217
1
vote
0 answers
How to properly include + register viewset routers with Django 2.0 DRF 3.8
I'm developing a basic Django DRF API. I have been using class-based views with explicit URLs. Now I'm trying to use very vanilla DRF ViewSets + router (for auto URL generation).
Can anybody help point me in the right direction? I'm on DRF 3.8 and…

mr530
- 11
- 4
1
vote
1 answer
Error when sending delete by ajax - Django Rest framework
I have 2 serializers:
class DetalleSerializer(serializers.ModelSerializer):
producto = serializers.CharField(source='producto.nombre')
class Meta:
model = DetalleVenta
fields = ('cantidad','producto')
class…

Piero Pajares
- 276
- 1
- 4
- 21
1
vote
0 answers
Django REST Framework: allow any user can edit any data (remove object_permission)
I am using Django REST Framework's viewsets.ModelViewSet to list, create, update and delete table rows. For the following Tasks model it works fine.
But it only allows to list, create, update and delete of own entries (i.e. resource owner) or the…

Arun SS
- 1,791
- 8
- 29
- 48
1
vote
1 answer
Django Rest Framework: Updating / creating multiple objects dynamically, without giving the pk
I just stumbled upon the hardest problem I ever had with Django Rest Framework. Let me give you my models first, and then explain:
class Stampcardformat(models.Model):
workunit = models.ForeignKey(
Workunit,
…

J. Hesters
- 13,117
- 31
- 133
- 249
1
vote
1 answer
Django REST framework not picking up API endpoint
I'm trying to refactor an API to use the Django REST framework. I've changed my urls.py to the following (still in Django 1.11):
from django.conf.urls import url
from . import views
from rest_framework import routers, serializers, viewsets
from…

Kurt Peek
- 52,165
- 91
- 301
- 526
1
vote
1 answer
Return NoneType on queryset django REST framework
Problem :
I am getting an error like this :
Traceback:
File
"/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py"
in inner
41. response = get_response(request)
File
…

hemo
- 110
- 1
- 10
1
vote
1 answer
Django Rest Framework change root item and list item element name
I am new to Django-Rest framework. I want to change root and list-item element name depending upon model names:
From:
worrier1
worrier2
To:
worrier1
…

Sajal Shrestha
- 98
- 7
1
vote
1 answer
send just a specific filed on ModelSerializer to client - django rest framework
I have a Serializer like below:
class KlassStudentSerializer(ModelSerializer):
student = ProfileSerializer()
klass = KlassSerializer()
class Meta:
model = KlassStudents
fields = ['pk', 'student', 'klass']
I want to send just klass…

msln
- 1,318
- 2
- 19
- 38