Notes & ideas
Writing about code, systems, and the things I learn.
A collection of practical notes from building backend software and exploring technology.
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 articleAggregating 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 articleContext in Views
In Django REST Framework, the `APIView` class and the `ModelViewSet` class handle the context dictionary differently, which may explain the differenc…
Read articleAPIView 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 articleCommon 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 articleAggregation 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 articlePermissions 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 articleField 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 articleAggregating 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 articleViewSets & 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