ConoscereLinux / asso-django

An open source Django Framework to manage Events, Member and basic Accounting for an Italian Association
GNU General Public License v3.0
0 stars 3 forks source link

Scripts | Missing fields in data migrated should be inserted as empty string or None bypassing full_clean validation #62

Closed giobber closed 1 year ago

giobber commented 1 year ago

When textual data migrated miss a value or is set to None, it should add it as empty string. To pass full_clean check the parameter exclude can be used


for field in textual_field_name:
    if not field in item or field is None:
        item[field]  = ""

exclude = [field for field, value in item.items() if value is ""]

member.full_clean(exclude=exclude)
giobber commented 1 year ago

No more needed, member data are skipped with an error log if invalid