Questions tagged [drf-nested-routers]
46 questions
2
votes
1 answer
How to achieve nested URL for OneToOne Relationship?
I'm a little bit stuck with the following situation. I want to build a REST API for a shopping cart app using the Django Rest Framework, however, due to legacy requirements I need to work with nested URLs.
In general, I have two resources AppUsers…

wuser92
- 479
- 3
- 16
2
votes
1 answer
Django Rest Framework Nested Routes - PK alternatives
I am using drf-nested-routers to nest my resources and everything is working well. I would like, however, to use something other than the pk to refer to a parent object.
What I currently have is:
api/movies/4/scenes - generates a list of scenes…

purplefloyd
- 155
- 1
- 12
2
votes
1 answer
Nested router not working
I'm new to Django and am struggling to get nested routers working. Basically, I'm trying to model the endpoint /api/v1/organizers/1/events/1, where I have Event and Organizer models as follows:
class Event(models.Model):
class Meta:
…

ankush981
- 5,159
- 8
- 51
- 96
2
votes
1 answer
Django Rest Framework Nested Urls
The models are
class Article(models.Model):
title = models.CharField(max_length=30)
class Categories(models.Model):
article = models.ForeignKey(Article)
name = models.CharField(max_length=30)
There is a possibility of using…

bobsr
- 3,879
- 8
- 30
- 37
2
votes
1 answer
No data gets transmitted via drf-nested-routers PUT
I try to update a object in my database via a PUT to my django backend.
The url I call is a PUT to:
API_HOST + '/vehicles/V-123'
It is routed like this to my update method:
from Tiresets.views import TiresetsSet
from Vehicles.views import…

Igl3
- 4,900
- 5
- 35
- 69
1
vote
1 answer
DRF nested router serializer source fields from url
I have an author and books model. An author has many books with him
class Author(Model):
id = UUIDField(primary_key=True, default=uuid4, editable=False)
name = CharField(max_length=50)
email = CharField(max_length=50)
class…

Dinesh Gowda
- 1,044
- 3
- 13
- 29
1
vote
1 answer
DRF Django - make routable reverse foreign key relationship data
I have the following models
# filename - stocks.models
class Stock(models.Model):
ticker = models.CharField(max_length=10, unique=True, primary_key=True)
exchange = models.CharField(default="", max_length=10)
name =…

Aran Freel
- 3,085
- 5
- 29
- 42
1
vote
1 answer
Django - reverse nested url with drf-nested-routers
I configured my api url as
localhost:port/app_name/students/{student_id}/macro/{macro_id}/lto
using drf-nested-routers extension. Basically, each students has some macro categories assigned, that in turns have some Long Term Objectives (LTOs). I've…

dc_Bita98
- 851
- 2
- 17
- 35
1
vote
1 answer
How to serialize the Infinite-depth nesting example using drf-nested-routers?
I am quite new to django-rest-framework. I am trying to combine the examples infinite-depth nesting and hyperlinks for nested resources in drf-nested-routers
I added a MailReply object just to try the infinite-depth nesting. When i try to access…

ejrcm
- 21
- 5
1
vote
2 answers
Django REST Framework generics.RetrieveUpdateDestroyAPIView return all records instead of one
I'm new to DRF and trying to build a rest API, I have set up my models, URLs, views, and serializers as:
model.py:
services = (
('Single', 'Single'),
('Multiple', 'Multiple'),
)
class DeploymentOnUserModel(models.Model):
…

Abdul Rehman
- 5,326
- 9
- 77
- 150
1
vote
0 answers
DRF nested routers could not resolve URL for hyperlinked relationship
I am trying to use drf-nested-routers to create a nested url pattern like the following:
/projects/{project_pk}/join_request/{pk}
With my current setup, I am able to navigate to /projects successfully, and see the list of hyperlinked…

doomblah
- 77
- 2
- 10
1
vote
0 answers
DRF nested routers: Improperly configured URL
I am trying to build an app using the DRF's quickstart guide. The app has the following setup
/school/
/school/
/school//courses/
/school//courses/
/school//courses//members/
When I follow the quickstart I get the following…

N. Dury
- 3
- 1
- 7
1
vote
1 answer
django DRF: how to Get related model field in serializer
I'm trying to return a HttpResponse from Django Rest Framework including data from 3 linked models. The models are
class ErrorDb(models.Model):
error_id = models.AutoField(primary_key=True)
error_msg = models.CharField(max_length=500)
…

vm-power
- 43
- 7
1
vote
1 answer
Django REST framework serializer error when instantiating
I'm having an strange issue with DRF ans some serializers.
Here is my model:
class Accommodation(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
product =…

AlejandroVK
- 7,373
- 13
- 54
- 77
1
vote
1 answer
Django REST drf-nested-routers does not trigger permission check
I'm using drf-nested-routers with ModelViewSets. Everything works fine, however, permissions checks on an resource/object are not being executed.
When dealing with a single resource/un-nested url, the permission checks get executed.
Is there…

dez
- 2,195
- 6
- 25
- 29