Skip to content

Instantly share code, notes, and snippets.

# mypy: ignore-errors
# flake8: noqa
# This file is autogenerated by /metadata-ingestion/scripts/avro_codegen.py
# Do not modify manually!
# pylint: skip-file
# fmt: off
# The SchemaFromJSONData method only exists in avro-python3, but is called make_avsc_object in avro.
@mishbahr
mishbahr / query_cache.py
Last active February 19, 2018 19:26
Generates a cache key from a Django Queryset
from hashlib import sha1
from django.utils.six import text_type
def get_queryset_cache_key(queryset):
"""Generates a cache key from a Queryset"""
db = queryset.db
compiler = queryset.query.get_compiler(using=db)
sql, params = compiler.as_sql()