The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.
# pulling one User object
user = User.query.get(1)
{ | |
'dates': { | |
3: { | |
'color': { | |
'main': u '#2B2B4A', | |
'primary': u '#5B4C7E', | |
'secondary': u '#DCCCFF' | |
}, | |
'date': datetime.date(2018, 11, 4), | |
'theme': u 'Python', |
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 OptimizeModelViewSetMetaclass(type): | |
""" | |
This metaclass optimizes the REST API view queryset using `prefetch_related` and `select_related` | |
if the `serializer_class` is an instance of `serializers.ModelSerializer`. |
The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.
# pulling one User object
user = User.query.get(1)
#!/usr/bin/env bash | |
# set your own root folders, all children folders will become options for in sessionizer menu | |
root_folders="$HOME/projects $HOME/work $HOME/.config" | |
function attach_session() { | |
local session_root=$1 | |
local session_name=$(basename "$session_root" | tr . _) | |
cd $session_root | |
zellij attach --create $session_name |