Commit 4fcc3899 authored by Hamza Dely's avatar Hamza Dely

[note_kfet/mixins] Utilise des champs par défaut avec le DynamicFieldsMixin

parent 0c33eb5d
......@@ -18,7 +18,12 @@ class DynamicFieldsMixin(object):
utilisés dans un sérialiseur.
"""
def __init__(self, *args, **kwargs):
fields = set(kwargs.pop('fields', []))
if getattr(self.__class__.Meta, 'default_empty', True):
default_fields = []
else:
default_fields = self.__class__.Meta.fields
fields = set(kwargs.pop('fields', default_fields))
super().__init__(*args, **kwargs)
for field in set(self.fields) - fields:
self.fields.pop(field)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment