Notes & ideas

Writing about code, systems, and the things I learn.

A collection of practical notes from building backend software and exploring technology.

ARTICLE

Differences 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 article
ARTICLE

Aggregating and Annotating Objects

The Django web framework includes a default object-relational mapping layer (ORM) for interacting with data from relational databases such as SQLite,…

Read article
ARTICLE

Context in Views

In Django REST Framework, the `APIView` class and the `ModelViewSet` class handle the context dictionary differently, which may explain the differenc…

Read article
ARTICLE

APIView vs. ViewSet in Django REST Framework

In Django REST Framework (DRF), you can choose between `APIView` and `ViewSet` depending on your specific requirements and preferences. `APIView` is …

Read article
ARTICLE

Common Serializer Methods in Django REST Framework

In Django, serializers are used to convert complex data types, such as Django model instances, into a format (e.g., JSON, XML) that can be easily ren…

Read article
ARTICLE

Aggregation in Django

Django’s aggregate() method calculates a summary value across a queryset. In this example, Sum totals the hours worked by one teammate for each repor…

Read article
ARTICLE

Permissions in Django

1) Custom PermissionsTo create custom permissions for a given model object, use the permissions model Meta attribute.This example Task model creates …

Read article
ARTICLE

Field Lookups in Django

In Django, field lookups are used to perform queries on model fields to retrieve specific data from the database. They allow you to filter, order, an…

Read article
ARTICLE

Aggregating and Annotating Objects in Django

OverviewThe Django web framework includes a default object-relational mapping layer (ORM) for interacting with data from relational databases such as…

Read article
ARTICLE

ViewSets & APIViews in Django

In Django, you can use either ViewSets or APIViews to create APIs for your web application. Here are some factors to consider when choosing between V…

Read article