Linked Questions

28 votes
4 answers
46k views

The `.create()` method does not support writable nested fields by default.

I have a big problem regarding the serialization of a Many to Many relationship with intermediate model in DRF: If the request method is get everything works perfectly. But as soon as i try to POST or ...
nictec's user avatar
  • 285
15 votes
1 answer
6k views

Nested field serializer - Data missing

Related to this Topic Hi, I cannot follow the answer at the attached topic, because an ID is missing after serialization. Model.py class Owner(models.Model): name = models.CharField(db_index=...
CheapD AKA Ju's user avatar
27 votes
3 answers
14k views

Writable nested serializer with existing objects using Django Rest Framework 3.2.2

Consider a Listing model that has an associated Category. I want to create a new Listing for an existing Category by doing a POST with data: {"title": "myapp", "category": {"name": "Business"}}, ...
arw180's user avatar
  • 401
18 votes
2 answers
17k views

ModelViewSet - Update nested field

I'm currently working on Django with Django Rest Framwork. I can't update my object within nested object field. serializer.py class OwnerSerializer(serializers.ModelSerializer): class Meta: ...
CheapD AKA Ju's user avatar
1 vote
4 answers
7k views

Django rest framework get or create for PrimaryKeyRelatedField

I start to create REST API for my web-application with Django and Django rest framework and I need one logic problem. There are entities Instruction and Tag. The user visit my service and create ...
Stan Zeez's user avatar
  • 1,138
5 votes
2 answers
8k views

Django Rest Framework update nested serializer

I have a big misunderstanding with DRF nested serializers. I read docs about this and found out that I need to provide my own update method. So, here it is: class SkillsSerializer(serializers....
NONAMA's user avatar
  • 513
4 votes
0 answers
2k views

Improperly configured nested resource using HyperlinkedModelSerializer

I have chosen the Django REST Framework and drf-nested-routers to build an API for Products and ProductReports. Here are the relevant classes: # models.py from django.db import models class Product(...
JJD's user avatar
  • 50.7k
3 votes
1 answer
1k views

Django REST Framework: Flatten nested JSON to many objects

I have this child model with parent field in it, and I'm getting a JSON from an API (which I can't control its format). models.py: class ChildModel(models.Model): name = models.CharField(...
user1557330's user avatar
0 votes
1 answer
1k views

How to use drf-writable-nested to create-or-update?

I took the Django drf-writable-nested package and made it a complete implementation called drf-writable-example by adding a bit of REST code (see below). (See drf-writable-nested page for the models ...
dfrankow's user avatar
  • 20.6k
1 vote
1 answer
255 views

Displaying nested entities in Django REST Framework

I would like to display nested entities in the Django REST response – not hyperlinked entities or primary keys - the actual entity inside the parent. This would look something like this: { 'id': 5 ...
Gorbie Chev's user avatar
0 votes
1 answer
196 views

python djaango-rest-framework 3.3.3 update nested serializer

Using django-rest framework 3.3.3 I am trying to update existing data in my database using the django-rest framework, following a previously posted solution :django-rest-framework 3.0 create or ...
C.Matthews's user avatar
1 vote
0 answers
159 views

Update Nested Relation Django-Rest-Framework 3

Assuming I have this models.py: class HRSubject(modes.Model): group = models.ForeignKey(Group, related_name="hrsubjects") name = models.CharField(max_length=256) and my serializes are: ...
Tal Peretz's user avatar
0 votes
0 answers
58 views

Reading and creating nested relation in single serializer django

I have two models Category and Products, and a classic one to many relatoin between them. Each product belongs to a category. I am using Django-Rest-Framework. I am using ModelViewSet as a ViewSet ...
Rami ZK's user avatar
  • 530