Enzo Yair

se agrego usuario_movimiento a el modelo edicto

# Generated by Django 4.1.9 on 2023-09-12 21:23
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('edicto', '0013_alter_edicto_estado'),
]
operations = [
migrations.AddField(
model_name='edicto',
name='usuario_movimiento',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='udate_edicto', to=settings.AUTH_USER_MODEL),
),
]
... ...
# Generated by Django 4.1.9 on 2023-09-12 21:24
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
def migrar_edicto_usuario_movi(apps, schema):
Edictos = apps.get_model('edicto', 'Edicto')
user_move = 1
for edicto in Edictos.objects.all():
edicto.usuario_movimiento = user_move
edicto.save()
user_move = user_move+1
class Migration(migrations.Migration):
dependencies = [
('edicto', '0014_edicto_usuario_movimiento'),
]
operations = [
migrations.RunPython(migrar_edicto_usuario_movi, reverse_code=migrations.RunPython.noop),
migrations.AlterField(
model_name='edicto',
name='usuario_movimiento',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='udate_edicto', to=settings.AUTH_USER_MODEL)
),
]
... ...
... ... @@ -38,6 +38,7 @@ class Edicto(models.Model):
observaciones = models.CharField(max_length=500, blank=True, null=True)
fecha_creacion = models.DateField(auto_now_add=True)
fecha_modificacion = models.DateTimeField(auto_now_add=True)
usuario_movimiento = models.ForeignKey(Usuario, on_delete=models.CASCADE, related_name='udate_edicto')
class Meta:
verbose_name = 'Edicto'
... ...