Skip to content

Instantly share code, notes, and snippets.

@solanoize
Created June 16, 2019 09:34
Show Gist options
  • Select an option

  • Save solanoize/fe75698c02f78134208fd51db3d4a946 to your computer and use it in GitHub Desktop.

Select an option

Save solanoize/fe75698c02f78134208fd51db3d4a946 to your computer and use it in GitHub Desktop.
Cara menggunakan context helper pagination.
...
def present(self):
queryset = self.context.get('queryset')
request = self.context.get('request')
pagination, queryset = ContextHelper(HelperPagination(context={
'queryset': queryset,
'request': request,
'limit': 20,
})).do_helpme()
for order in queryset:
pagination['results'].append({
'order_number': order.order_number,
'user': {
'username': order.user.username,
'email': order.user.email,
'first_name': order.user.first_name,
'last_name': order.user.last_name
},
'bill_to': {
'username': order.bill_to.username,
'email': order.bill_to.email,
'first_name': order.bill_to.first_name,
'last_name': order.bill_to.last_name
},
'status': order.get_status_display(),
'company': order.company.name,
'grand_total': order.grand_total,
'estimate': order.estimate,
'is_downpayment': order.is_downpayment,
'initial_payment': order.initial_payment,
'deadline': self.get_order_deadline(order),
})
return pagination
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment