Sistema de Apoio ao Processo Legislativo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

18 lines
677 B

from django.db import models
from sapl.utils import sapl_appconfs
def convert_null_to_empty():
for app in sapl_appconfs:
for model in app.get_models():
print('Convertendo null p/ vazio. model [%s]'
% model._meta.model_name)
char_fields = [f for f in model._meta.fields
if isinstance(f, (models.CharField,
models.TextField))]
for obj in model.objects.all():
for field in char_fields:
if getattr(obj, field.name) is None:
setattr(obj, field.name, '')
obj.save()