Multiple serializers

61 views
Skip to first unread message

miguel angel lopez mendo

unread,
Dec 10, 2015, 1:27:26 PM12/10/15
to Django users
i have this serializers 

class ValuarCoche(serializers.ModelSerializer):
class Meta:
model = Valuacion
depth = 6
fields = ('coche','Precio_Venta','Precio_Compra')

class CocheSerializer2(serializers.ModelSerializer):
valuacion = ValuarCoche(many=True)
class Meta:
model = Coche


        fields = ('id', 'marca', 'modelo', 'version', 'estado','anio','timestamp','valuacion')


but don't work  i need that print 


{
        "id": 3,
        "marca": {
            "id": 1,
            "nombre": "Acura"
        },
        "modelo": {
            "id": 1,
            "nombre": "ILX"
        },
        "version": "a5",
        "estado": "1",
        "anio": 2015,
        "timestamp": "2015-12-08T19:12:05.887126Z"
         "Precio_Venta": 0,
        "Precio_Compra": 0
    },


the error is the next 

miguel angel lopez mendo

unread,
Dec 11, 2015, 1:21:14 PM12/11/15
to Django users
any ?

Daniel Chimeno

unread,
Dec 11, 2015, 9:21:07 PM12/11/15
to Django users
This question is more about DRF than Django itself, I haven't use it for a while so I can't answer you,
but please, put the code in a proper format way or pastebin, and say the version you are using both Django and DRF
in order other people can answer you.

Bruno A.

unread,
Dec 14, 2015, 5:17:13 AM12/14/15
to Django users
Also having your models would be helpful.

Mandeep Tondak

unread,
Dec 14, 2015, 6:12:09 AM12/14/15
to django...@googlegroups.com
Hi,


I thing you have an error in you queryset.



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/811a040b-6ad0-49a8-be5d-2e2981ff4e4b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Warm Regard:-
Mandeep Kumar
     



Reply all
Reply to author
Forward
0 new messages