daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Sep 25th, 2018 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class SliderImageSerializers(serializers.ModelSerializer):
  2.     class Meta:
  3.         model=SliderImage
  4.         fields='url','rank'
  5.  
  6. class ItemVariationsSerializer(serializers.ModelSerializer):
  7.     # items = ItemsSerializer(many=True, read_only=True)
  8.     class Meta:
  9.         model = ItemVariation
  10.         fields ='price','item_code','image'
  11.  
  12. class RestaurantSerializers(serializers.ModelSerializer):
  13.     items = ItemVariationsSerializer(many=True, read_only=True)
  14.     sliders = SliderImageSerializers(many=True, read_only=True)
  15.     class Meta:
  16.         model=Restaurant
  17.         fields=('__all__')
  18.    
  19. class ItemVariation(models.Model):
  20.     restaurant=models.ForeignKey(Restaurant,on_delete=models.CASCADE)
  21.     item=models.ForeignKey(Item,on_delete=models.CASCADE)
  22.     price=models.IntegerField(blank=True,null=True,default=0)
  23.     item_code=models.CharField(max_length=500)
  24.     keyword= models.ManyToManyField(Keyword)
  25.     image=models.ImageField(upload_to='dishes/', blank=True, null=True)
  26.  
  27.     def __str__(self):
  28.         return str(self.id)
  29.    
  30. {
  31.     "id": 1,
  32.     "sliders": [
  33.         {
  34.             "url": "/media/restaurant/download_2.jpeg",
  35.             "rank": 1
  36.         }
  37.     ],
  38.     "name": "Haveli",
  39.     "email": "test@tet.com",
  40.     "web": "wdew",
  41.     "short_description": "dsfsdf",
  42.     "description": "fsdfsd",
  43.     "phone": 21315,
  44.     "lat": 30.704649,
  45.     "lng": 76.717873,
  46.     "address1": "dsff",
  47.     "address2": "vfdg",
  48.     "city": "sdfds",
  49.     "state": "fs",
  50.     "postalcode": "sdfsd",
  51.     "avg_rating": 1,
  52.     "price": 0,
  53.     "restaurant_type": 1,
  54.     "keywords": [
  55.         1,
  56.         2,
  57.         3
  58.     ]
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top