Skip to content

Instantly share code, notes, and snippets.

@robintema
robintema / pagination.py
Created November 2, 2016 15:08
Django Rest Framework custom pagination class
from rest_framework.pagination import PageNumberPagination, _positive_int
class CustomPageNumberPagination(PageNumberPagination):
""" A custom DRF paginator class
"""
# Client can control the page using this query parameter.
page_query_param = 'page'
# Client can control the page size using this query parameter.
@robintema
robintema / GeneralSerializer.py
Last active December 7, 2020 14:10
General Django Rest Framework model serializer
import logging
from rest_framework import serializers
class GeneralModelSerializer(serializers.ModelSerializer):
""" General model serializer that will serialize a model object. It will return all the model fields.
"""
class Meta:
model = None
<?php
namespace MyFunnyValentine;
// Detect if the currently matched route belongs to this module.
// The assumption is that the controller name includes the module namespace.
class Module
{
public function onBootstrap($e)

Awesome PHP

A list of amazingly awesome PHP libraries, resources and shiny things.

Composer