|
@ -1,11 +1,13 @@ |
|
|
from django.db import models |
|
|
from django.db import models |
|
|
|
|
|
|
|
|
from sapl.utils import sapl_appconfs |
|
|
from django.apps import apps |
|
|
|
|
|
from sapl.settings import SAPL_APPS |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def convert_null_to_empty(): |
|
|
def convert_null_to_empty(): |
|
|
for app in sapl_appconfs: |
|
|
for name in SAPL_APPS: |
|
|
for model in app.get_models(): |
|
|
for model in apps.get_app_config(name).get_models(): |
|
|
|
|
|
try: |
|
|
print('Convertendo null p/ vazio. model [%s]' |
|
|
print('Convertendo null p/ vazio. model [%s]' |
|
|
% model._meta.model_name) |
|
|
% model._meta.model_name) |
|
|
char_fields = [f for f in model._meta.fields |
|
|
char_fields = [f for f in model._meta.fields |
|
@ -16,3 +18,5 @@ def convert_null_to_empty(): |
|
|
if getattr(obj, field.name) is None: |
|
|
if getattr(obj, field.name) is None: |
|
|
setattr(obj, field.name, '') |
|
|
setattr(obj, field.name, '') |
|
|
obj.save() |
|
|
obj.save() |
|
|
|
|
|
except Exception as e: |
|
|
|
|
|
print(e) |
|
|