forked from swist/django-more
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__init__.py
25 lines (19 loc) · 846 Bytes
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from importlib import reload, import_module
# Project imports
from patchy import patchy
default_app_config = 'django_cte.apps.DjangoCTEConfig'
def patch_cte():
""" Apply CTE monkey patches to Django.
At present these patches must be updated manually to conform with new CTE
implementations, but this is only necessary to use new functionality.
Order of patching *matters* due to namespace reload.
"""
with patchy('django.db.models', 'django_cte') as p:
p.mod('expressions').auto()
p.mod('sql.compiler').auto()
p.mod('sql.subqueries').auto()
# Force reload so that new query types are imported into namespace
reload(import_module('django.db.models.sql'))
p.mod('query').auto()
p.cls('manager.BaseManager').auto()
p.cls('base.Model').auto()