Skip to content
Advertisement

Tag: django-serializer

Serialize a queryset including the ForeignKey values

models.py: views.py: I would like to return a json response with the content of ProjectManager + the content of the Project associated to that ProjectManager (ForeignKey). According to what I have read in the Django documentation, to do a left join, the best thing to do would be to use select_related. In fact, it works, but when I serialize ProjectManager,

Django Rest Framework: Access to passed arguments from views in serializers

Before asking this question, I have seen the following links but they don’t help me at all: pass extra arguments to serializer pass request context to serializer from viewset pass context from one serializer to another I have an author model that has foreign key to default django user model: apps/author/models.py Post model has a foreign key to Author. apps/posts/models.py

Django rest framework’s StringRelatedField is throwing KeyError

I have the following model classes. and I have imported these classes as following as they are located in a separate package and this is my serializer class and views is and url has the following I am getting the following error I looked into the DRF example and this seems to be a simple thing to achieve. https://www.django-rest-framework.org/api-guide/relations/#api-reference But

Advertisement