Skip to content

Instantly share code, notes, and snippets.

View dz0's full-sized avatar

Jurgis Pralgauskis dz0

  • 11:13 (UTC +02:00)
View GitHub Profile
@dz0
dz0 / drf_optimize.py
Created November 29, 2018 09:23 — forked from jackton1/drf_optimize.py
MetaClass to Improve DRF ModelViewsSet query.
from django.db import ProgrammingError, models
from django.db.models.constants import LOOKUP_SEP
from django.db.models.query import normalize_prefetch_lookups
from rest_framework import serializers
from rest_framework.utils import model_meta
class OptimizeRelatedModelViewSetMetaclass(type):
"""
This metaclass optimizes the queryset using `prefetch_related` and `select_related`.
@dz0
dz0 / code_quotes.txt
Created April 26, 2018 02:33 — forked from OnesimusUnbound/quote.txt
Programming Quotes
[T]he difference between a bad programmer and a
good one is whether he considers his code or his
data structures more important. Bad programmers
worry about the code. Good programmers worry about
data structures and their relationships.
-- Linus Torvalds
~~~
Clarity and brevity sometimes are at odds.
When they are, I choose clarity.
-- Jacob Kaplan-Moss