diff options
author | Alexander Sulfrian <alexander.sulfrian@fu-berlin.de> | 2015-09-23 20:25:49 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander.sulfrian@fu-berlin.de> | 2015-09-23 20:46:21 +0200 |
commit | 7cc349e27836f760e2a14b65e690473bd63bf3ad (patch) | |
tree | 82593aab3e25afee66bafd719fec6a4087a37e1a /src/lib/Bcfg2/Reporting | |
parent | e438e6f1003389c290a4811190f8b83a1abc743e (diff) | |
download | bcfg2-7cc349e27836f760e2a14b65e690473bd63bf3ad.tar.gz bcfg2-7cc349e27836f760e2a14b65e690473bd63bf3ad.tar.bz2 bcfg2-7cc349e27836f760e2a14b65e690473bd63bf3ad.zip |
Reporting: Replace _meta.get_all_field_names() for django 1.8
The _meta API was changed with django 1.8 and get_fields() now returns all
model fields even fields defined in related models. But while creating the
Entries we use this field list for construction and the list should only
contain local fields.
Diffstat (limited to 'src/lib/Bcfg2/Reporting')
-rw-r--r-- | src/lib/Bcfg2/Reporting/Storage/DjangoORM.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Reporting/Storage/DjangoORM.py b/src/lib/Bcfg2/Reporting/Storage/DjangoORM.py index 7acd9e293..ac0cde783 100644 --- a/src/lib/Bcfg2/Reporting/Storage/DjangoORM.py +++ b/src/lib/Bcfg2/Reporting/Storage/DjangoORM.py @@ -24,6 +24,16 @@ from Bcfg2.Reporting.models import * from Bcfg2.Reporting.Compat import transaction +def get_all_field_names(model): + if django.VERSION[0] == 1 and django.VERSION[1] >= 8: + return [field.name + for field in model._meta.get_fields() + if field.auto_created == False and + not (field.is_relation and field.related_model is None)] + else: + return model._meta.get_all_field_names() + + class DjangoORM(StorageBase): options = StorageBase.options + [ Bcfg2.Options.Common.repository, @@ -80,7 +90,7 @@ class DjangoORM(StorageBase): for attr in boolean + ["current_exists"]: xforms[attr] = boolean_xform act_dict = dict(state=state) - for fieldname in entrytype._meta.get_all_field_names(): + for fieldname in get_all_field_names(entrytype): if fieldname in ['id', 'hash_key', 'state']: continue try: |