Questions tagged [drf-nested-routers]
46 questions
1
vote
1 answer
drf nested routers - route subroutine for endpoint
I have a old endpoint with a URL like this:
url(r'^vehicles/([^/]{1,50})/trips/data/?$', 'vehicle_trip_data'),
which was mapped to my function based view.
I am now refactoring the works to work with drf-nested-routers.
What I know is, that I can…

Igl3
- 4,900
- 5
- 35
- 69
0
votes
1 answer
Django - Object of type User is not JSON serializable
I am facing an issue with POSTing data (which has a User object) to a ModelViewSet.
Error: "Object of type User is not JSON serializable"
data_params = {
"log_user_id": user,
"device_name": "sampledevice",
"log_user_email":…

Sindhujit
- 51
- 9
0
votes
1 answer
Why django-rest-framework is generating same api url for two views (both views having same queryset)?
My Project Configuration is this. This is realated to Contact Form. Here I have two approach: Customer from frontend can only post (i.e. send message) and admin can only retrieve and list the contacts.
Models.py
class Contact(models.Model):
…

Bibek
- 21
- 5
0
votes
1 answer
username with `james i. adams` not accepted with django routers
I have registered routers for user model, which has viewset that has lookup_url as username.
The username james adams is accepted by the router, but getting below error for james i. adams
django.urls.exceptions.NoReverseMatch: Reverse for…

sandeshdaundkar
- 883
- 1
- 7
- 14
0
votes
0 answers
How to create a very complicated route with DRF
I have 4 models: School, Class, Student, Address. I want to build an API like /api/schools/1/classes/2/students/3/address.
This example would return the address of student which has id 3, belongs to class 2 and school 1 (may be more complicated in…

SoT
- 898
- 1
- 15
- 36
0
votes
1 answer
Incorrect view name for nested hyperlinks using drf-nested-routers
I am attempting to use drf-nested-routers to create a simple nested Django REST API given the following models:
# models.py
class Podcast(models.Model):
title = models.CharField(max_length=125)
class Episode(models.Model):
podcast =…

Kjell-Bear
- 759
- 1
- 5
- 12
0
votes
2 answers
Django Rest Framework router - exclude URL for prefix
I am using DRF router with a prefix + include like this:
router = BulkRouter()
router.register(r"myfeature", MyfeatureViewSet, base_name="myfeature")
urlpatterns = [
url(r"^api/1/", include(router.urls)),]
This allows me to hit the both api/1…

s g
- 5,289
- 10
- 49
- 82
0
votes
1 answer
Django Rest Framework: nested serializer for duplicate rows, in the case of foreign key
serializer.py
class Car(serializers.ModelSerializer):
geography=Geography(read_only=True)
class Meta:
model = Car
fields = ['car_id', 'geography']
models.py
class Car(models.Model):
car_id =…

Anne Besant
- 1
- 3
0
votes
1 answer
django rest framework- serializers, read_only, and drf-nested-routers, how to set parent?
I have the following simple models for a todo list:
class TodoList(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
title = models.CharField(max_length=255)
class Todo(models.Model):
id =…

MarkD
- 4,864
- 5
- 36
- 67
0
votes
0 answers
Cannot create a NestedHyperlinkedIdentityField that is 2 levels deep from a source that is a reverse relation of parent using drf-nested-routers
I am trying to display the url of a nested route that is 2 or more levels deep using the drf-nested-routes module and the Django Rest Framework. I have no problems when it is only one level deep (i.e. getting the route with parent_lookup_kwargs),…

iosefa
- 1
- 1
- 1
0
votes
1 answer
Page not found erro with drf-nested-routers
I'm using
Django: 2.0
Djanfo REST Frameword: 3.8.2
drf-nested-routers: 0.90.2
My contacts/views.py
class ContactViewSet(viewsets.ModelViewSet):
serializer_class = ContactSerializer
permission_classes = (IsAuthenticated,)
def…

Anuj TBE
- 9,198
- 27
- 136
- 285
0
votes
1 answer
Django drf-nested-routers - model object has no attributed related field
I am creating an API using the drf-nested-routers application for Django Rest Framework. This application is a tracker where users have sessions and tasks. Each user can have three active tasks and can work on each of these tasks in a given…

Neighlyd
- 352
- 2
- 14
0
votes
2 answers
DRF + Nested-Routers - "QuerySet' object has no attribute 'user'
Using DRF and DRF-nested-routers
Here's my code:
class MemberViewSet(viewsets.ViewSet):
queryset = GroupMember.objects.all()
serializer_class = GroupMembersSerializer
def create(self, request, group_pk=None):
queryset =…

Danny
- 889
- 3
- 10
- 19
0
votes
1 answer
Django REST Framework Nested Routers - Pagination not working
I have a simple nested router using drf-nested-routers, similar to the example on the readme page. The list view on the nested route does not paginate at all, ignoring my DEFAULT_PAGINATION_CLASS setting. Is this by design? Do nested routes have to…

Neil
- 7,042
- 9
- 43
- 78
0
votes
1 answer
HyperlinkedRelatedField doesn't work in drf-nested-routers
I'm using drf-nested-routers as below
calendar_router = DefaultRouter()
calendar_router.register(r'calendars', views.CalendarViewSet, base_name='calendars')
event_router = routers.NestedSimpleRouter(calendar_router, r'calendars',…

Yuwen Yan
- 4,777
- 10
- 33
- 63