daily pastebin goal
37%
SHARE
TWEET

Untitled

a guest Jun 19th, 2017 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class ObjModelDetailSerializer(serializers.ModelSerializer):
  2.     class Meta:
  3.         model = ObjModel
  4.         fields = (
  5.             'month',
  6.             'year',
  7.             'objs'
  8.         )
  9.  
  10.     def get_month(self, obj):
  11.         if obj.date:
  12.             return obj.date.month
  13.  
  14.     def get_year(self, obj):
  15.         if obj.date:
  16.             return obj.date.year
  17.  
  18.     def get_invoices(self, obj):
  19.         qs = ObjModel.objects.filter(date__year=obj.date.year,
  20.                                      date__month=obj.date.month)
  21.         return ObjModelDetailSerializer(qs, many=True).data
RAW Paste Data
Top