This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN TRANSACTION; | |
CREATE TABLE "user" | |
( | |
"id" SERIAL PRIMARY KEY, | |
"name" VARCHAR NOT NULL, | |
"email" VARCHAR NOT NULL | |
); | |
CREATE TABLE "post" | |
( | |
"id" SERIAL PRIMARY KEY, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class cached_property(object): | |
""" | |
Decorator that converts a method with a single self argument into a | |
property cached on the instance. | |
""" | |
def __init__(self, func): | |
self.func = func | |
def __get__(self, instance, type=None): | |
if instance is None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import contextlib | |
from copy import deepcopy | |
from django.db.models.expressions import ExpressionNode, F | |
from django.db.models.fields.files import FileField | |
from django.db.models.query import QuerySet | |
from django.db import models, transaction | |
import operator | |
def get_object_or_none(cls, *args, **kwargs): |