Created
June 16, 2019 09:34
-
-
Save solanoize/fe75698c02f78134208fd51db3d4a946 to your computer and use it in GitHub Desktop.
Cara menggunakan context helper pagination.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| 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