Enzo Yair

se agrego atributo editable y se elimino field de read_only_fields

# Generated by Django 4.1.9 on 2023-09-19 13: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', '0015_edicto_usuario_movi'),
]
operations = [
migrations.RemoveField(
model_name='edicto',
name='usuario',
),
migrations.RemoveField(
model_name='edicto',
name='usuario_movimiento',
),
migrations.AddField(
model_name='edicto',
name='creado_por',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Usuario'),
preserve_default=False,
),
migrations.AddField(
model_name='edicto',
name='modificado_por',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='udate_edicto', to=settings.AUTH_USER_MODEL),
preserve_default=False,
),
]
... ...
# Generated by Django 4.1.9 on 2023-09-19 12:40
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('edicto', '0015_edicto_usuario_movi'),
]
operations = [
migrations.RenameField(
model_name='edicto',
old_name='usuario',
new_name='creado_por',
),
migrations.RenameField(
model_name='edicto',
old_name='usuario_movimiento',
new_name='modificado_por',
),
]
# Generated by Django 4.1.9 on 2023-09-19 13:29
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
('edicto', '0016_remove_edicto_usuario_and_more'),
]
operations = [
migrations.RemoveField(
model_name='edicto',
name='id',
),
migrations.AlterField(
model_name='edicto',
name='uuid',
field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True),
),
]
... ...
# Generated by Django 4.1.9 on 2023-09-19 13:34
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('edicto', '0017_remove_edicto_id_alter_edicto_uuid'),
]
operations = [
migrations.AlterField(
model_name='edicto',
name='fecha_modificacion',
field=models.DateTimeField(auto_now=True),
),
]
... ...
... ... @@ -25,8 +25,8 @@ class Precio (models.Model):
class Edicto(models.Model):
uuid = models.UUIDField(unique=True, editable=False, default=uuid4)
creado_por = models.ForeignKey(Usuario, on_delete=models.CASCADE, verbose_name='Usuario')
uuid = models.UUIDField(unique=True, editable=False, default=uuid4, primary_key=True)
creado_por = models.ForeignKey(Usuario, on_delete=models.CASCADE, verbose_name='Usuario', editable=False)
cuerpo_edicto = models.TextField(blank=False, null=False)
archivo = models.FileField(upload_to="uploads/%Y/%m/%d/", null=False, blank=False)
dias_publicar = models.PositiveIntegerField(blank=False, null=False)
... ... @@ -36,9 +36,9 @@ class Edicto(models.Model):
cantidad_copias = models.PositiveIntegerField(blank=False, null=False)
fecha_publicacion = models.DateField(blank=True, null=True)
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)
modificado_por = models.ForeignKey(Usuario, on_delete=models.CASCADE, related_name='udate_edicto')
fecha_creacion = models.DateField(auto_now_add=True, editable=False)
fecha_modificacion = models.DateTimeField(auto_now=True, editable=False)
modificado_por = models.ForeignKey(Usuario, on_delete=models.CASCADE, related_name='udate_edicto', editable=False)
class Meta:
verbose_name = 'Edicto'
... ...
... ... @@ -32,10 +32,7 @@ class EdictoSerializer(serializers.ModelSerializer):
)
read_only_fields = ('creado_por', 'modificado_por',
'fecha_publicacion', 'cantidad_palabras',
'fecha_creacion',
'fecha_modificacion',
read_only_fields = ('fecha_publicacion', 'cantidad_palabras',
)
def validate(self, data):
... ...