Thank for replying attaching my serializers file please review it.
On Wednesday, 8 June 2016 20:47:08 UTC+5:30, Mjumbe Poe wrote: > > Actually, if you have two Bus_detail objects in your database, then it > looks like it's pulling them. What does your Bus_detailSerializer look > like? It seems to me that there are no fields in the serializer's > definition. > > On Wed, Jun 8, 2016 at 6:42 AM Harshit Sharma <[email protected] > <javascript:>> wrote: > >> Hi Everyone, >> >> I am creating a django-rest-api , when i am running api for testing in >> browser , not geting any >> >> getting output in this form- >> >> HTTP 200 OKAllow: GET, HEAD, OPTIONSContent-Type: application/jsonVary: >> Accept >> [ >> {}, >> {}] >> >> *i have entered data in database using django admin .* >> >> *please help me i am new to django restframework* >> >> -- >> 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 [email protected] <javascript:> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
from rest_framework import serializers from .models import Bus_detail,Car_detail,Travel_detail,Transporter,Bus_Route,Stations class Bus_detailSerializer(serializers.Serializer): class Meta: model=Bus_detail fields = '__all__' '''class Car_detailSerializer(serializers.Serializer): reg_no = serializers.CharField(max_length=90) #Type = ListField() capacity = serializers.IntegerField() Rating = serializers.DecimalField(max_digits=5,decimal_places=2) car_no= serializers.CharField(max_length=60) class Travel_detailSerializer(serializers.Serializer): bus_id = serializers.ForeignKey(Bus_detail) car_id = serializers.ForeignKey(Car_detail) #intermediate_station = ListField() boarding =serializers.CharField(max_length=70) dropping =serializers.CharField(max_length=70) fare = serializers.DecimalField(max_digits=50000,decimal_places=2) class TransporterSerializer(serializers.Serializer): name = serializers.CharField(max_length=60) address = serializers.CharField(max_length=60) Rating = serializers.DecimalField(max_digits=5,decimal_places=2) lic_no=serializers.IntegerField() contact_no=serializers.IntegerField() class Bus_RouteSerializer(serializers.Serializer): bus_id = serializers.ForeignKey(Bus_detail) source = serializers.CharField(max_length=70) destination = serializers.CharField(max_length=70) distance = serializers.IntegerField() class Stations(serializers.Serializer): name = serializers.CharField(max_length=70) code = serializers.IntegerField() lng = serializers.DecimalField(max_digits=500,decimal_places=2) lat = serializers.DecimalField(max_digits=500,decimal_places=2) contact = serializers.CharField(max_length=90)'''
