diff options
author | Sol Jerome <sol.jerome@gmail.com> | 2015-10-01 19:58:20 -0500 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2015-10-01 19:58:20 -0500 |
commit | 35a2ad1d76790b62b3dbb41cb7fa112c81dc4d5f (patch) | |
tree | a451a77147bc9fabce6e224e2038eedc78e27969 /src/lib/Bcfg2/Reporting/models.py | |
parent | 061bd6abbb598659554f28a1a5bba45fd6eca6da (diff) | |
parent | a505fb3b2df0d1eddfe7a92afb080b016e951a43 (diff) | |
download | bcfg2-35a2ad1d76790b62b3dbb41cb7fa112c81dc4d5f.tar.gz bcfg2-35a2ad1d76790b62b3dbb41cb7fa112c81dc4d5f.tar.bz2 bcfg2-35a2ad1d76790b62b3dbb41cb7fa112c81dc4d5f.zip |
Merge branch 'fix/django1.7' of https://github.com/AlexanderS/bcfg2
Diffstat (limited to 'src/lib/Bcfg2/Reporting/models.py')
-rw-r--r-- | src/lib/Bcfg2/Reporting/models.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/lib/Bcfg2/Reporting/models.py b/src/lib/Bcfg2/Reporting/models.py index 8e2c644fb..6ba7d3765 100644 --- a/src/lib/Bcfg2/Reporting/models.py +++ b/src/lib/Bcfg2/Reporting/models.py @@ -1,9 +1,10 @@ """Django models for Bcfg2 reports.""" import sys +import django from django.core.exceptions import ImproperlyConfigured try: - from django.db import models, backend, connections + from django.db import models, connections except ImproperlyConfigured: e = sys.exc_info()[1] print("Reports: unable to import django models: %s" % e) @@ -61,11 +62,15 @@ def _quote(value): """ global _our_backend if not _our_backend: - try: - _our_backend = backend.DatabaseOperations( - connections[get_db_label('Reporting')]) - except TypeError: - _our_backend = backend.DatabaseOperations() + if django.VERSION[0] == 1 and django.VERSION[1] >= 7: + _our_backend = connections[get_db_label('Reporting')].ops + else: + from django.db import backend + try: + _our_backend = backend.DatabaseOperations( + connections[get_db_label('Reporting')]) + except TypeError: + _our_backend = backend.DatabaseOperations() return _our_backend.quote_name(value) |