Enzo Yair

se agrega el valor id por defecto

# Generated by Django 4.1.9 on 2023-09-25 11:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('edicto', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='edicto',
name='uuid',
),
migrations.AddField(
model_name='edicto',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
preserve_default=False,
),
]
... ...
# Generated by Django 4.1.9 on 2023-09-25 11:29
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
('edicto', '0002_remove_edicto_uuid_edicto_id'),
]
operations = [
migrations.AddField(
model_name='edicto',
name='uuid',
field=models.UUIDField(default=uuid.uuid4, editable=False, null=True, unique=True),
),
]
... ...
# Generated by Django 4.1.9 on 2023-09-25 11:35
from django.db import migrations, models
import uuid
def migrar_datos_uuid(apps, schema):
Edictos = apps.get_model('edicto', 'Edicto')
for edicto in Edictos.objects.all():
edicto.uuid = uuid.uuid4()
edicto.save()
class Migration(migrations.Migration):
dependencies = [
('edicto', '0003_edicto_uuid'),
]
operations = [
migrations.RunPython(migrar_datos_uuid, reverse_code=migrations.RunPython.noop),
migrations.AlterField(
model_name='edicto',
name='uuid',
field=models.UUIDField(default=uuid.uuid4, editable=False, unique=True),
),
]
... ...
... ... @@ -15,6 +15,7 @@ class EdictoSerializer(serializers.ModelSerializer):
class Meta:
model = Edicto
fields = (
'uuid',
'creado_por',
'modificado_por',
'estado',
... ...