HELP-ME | SERIALIZERS DJANGO REST RELATIONS MANY-TO-MANY

55 views
Skip to first unread message

Marcus Quintela

unread,
Jun 1, 2016, 2:45:12 PM6/1/16
to Django REST framework
I am not able to bring in my REST API data from another table.

The scenario is as follows.

I have a kind of "team" that relates to the "User" class.
Therefore a join table was generated to join these classes in the database. So far so beautiful.

But my JSON NOT bring me the necessary information. Example:

{
    "Id": 1,
    "Name": "TEAM 1"
    "Datainicio", "08/18/2015",
    "EndDate" "09/20/2015"
    "Situation": "Enable"
    "User": [
        1,
       2
    ]
}

I did all the procedures as documentation of serializers relations. I created two separate serializers and called USER serializer in TEAM, but nothing appears.

http://www.django-rest-framework.org/api-guide/relations/#serializer-relations

I need him to return me in a personalized way:

    "Id": 1,
    "Name": "TEAM 1"
    "Datainicio", "08/18/2015",
    "EndDate" "09/20/2015"
    "Situation": "Enable"
    "User": [
        { "Id": 1, "username", "Alisson"},
        { "Id": 2, "username", "Malachi"}
    ]

Felipe Rodrigues

unread,
Jun 1, 2016, 9:31:01 PM6/1/16
to django-res...@googlegroups.com
Can you send the code for your serializers?

--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marcus Quintela

unread,
Jun 2, 2016, 1:19:42 PM6/2/16
to Django REST framework
Reply all
Reply to author
Forward
0 new messages