Notes & ideas
Writing about code, systems, and the things I learn.
A collection of practical notes from building backend software and exploring technology.
Customizing the Retrieve Method in a ViewSet
Override a ViewSet’s retrieve() method when a detail response needs related data beyond the default serializer output. Fetch the object with get_obje…
Read articleUsing Pagination and Filters in a ViewSet List Method
Django REST Framework’s filtering and pagination hooks are applied automatically by ListModelMixin.list(). A custom list action should call filter_qu…
Read articleShowing On/Off Icons for Calculated Boolean Fields
Django admin can display its standard yes/no icons for a calculated value, not only for model BooleanFields. Add the method to list_display, return a…
Read articleRunning a Standalone Script in Django
A standalone Python module can use Django models and services after Django’s settings and app registry have been initialized. Set DJANGO_SETTINGS_MOD…
Read articleDumping and Restoring a PostgreSQL Database
To dump a PostgreSQL database located at a specific IP address and restore it to a new database, you can follow these steps: 1. Dumping the database:…
Read articleStart Neo4j
Neo4j provides drivers which allow you to make a connection to the database and develop applications which create, read, update, and delete informati…
Read articleCustom Exception
importsfrom rest_framework.exceptions import PermissionDenied from rest_framework import status define classclass CustomExcpetion(PermissionDenied…
Read articlePagination in Django REST Framework
Example code: from rest_framework.pagination import PageNumberPagination from rest_framework.response import Response __all__ = ['DefaultPagina…
Read articleDifferences between has_object_permission and has_permission
We have following two permission methods on BasePermission class:def has_permission(self, request, view)def has_object_permission(self, request, view…
Read articleData Visualization
Before jumping into the term “Data Visualization”, let’s have a brief discussion on the term “Data Science” because these two terms are interrelated.…
Read article