Skip to content

Instantly share code, notes, and snippets.

@chibisov
Created March 3, 2015 07:07
Show Gist options
  • Save chibisov/e3d2c1c6660935c67291 to your computer and use it in GitHub Desktop.
Save chibisov/e3d2c1c6660935c67291 to your computer and use it in GitHub Desktop.
class QuerySet(object):
def __init__(self, query=None):
self.query = query or {}
def _clone(self):
return type(self)(query=deepcopy(self.query))
def __getitem__(self, k):
if isinstance(k, slice):
def all(self):
return self._clone()
def filter(self, **kwargs):
clone = self._clone()
clone.query.update(kwargs)
return clone
def count(self):
raise NotImplementedError()
def exists(self):
raise NotImplementedError()
def get(self, *args, **kwargs):
raise NotImplementedError()
def order_by(self, *field_names):
raise NotImplementedError()
def distinct(self, *field_names):
raise NotImplementedError()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment