se agrego atributo editable y se elimino field de read_only_fields
Showing
6 changed files
with
83 additions
and
32 deletions
1 | +# Generated by Django 4.1.9 on 2023-09-19 13:23 | ||
2 | + | ||
3 | +from django.conf import settings | ||
4 | +from django.db import migrations, models | ||
5 | +import django.db.models.deletion | ||
6 | + | ||
7 | + | ||
8 | +class Migration(migrations.Migration): | ||
9 | + | ||
10 | + dependencies = [ | ||
11 | + migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
12 | + ('edicto', '0015_edicto_usuario_movi'), | ||
13 | + ] | ||
14 | + | ||
15 | + operations = [ | ||
16 | + migrations.RemoveField( | ||
17 | + model_name='edicto', | ||
18 | + name='usuario', | ||
19 | + ), | ||
20 | + migrations.RemoveField( | ||
21 | + model_name='edicto', | ||
22 | + name='usuario_movimiento', | ||
23 | + ), | ||
24 | + migrations.AddField( | ||
25 | + model_name='edicto', | ||
26 | + name='creado_por', | ||
27 | + field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Usuario'), | ||
28 | + preserve_default=False, | ||
29 | + ), | ||
30 | + migrations.AddField( | ||
31 | + model_name='edicto', | ||
32 | + name='modificado_por', | ||
33 | + field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='udate_edicto', to=settings.AUTH_USER_MODEL), | ||
34 | + preserve_default=False, | ||
35 | + ), | ||
36 | + ] |
1 | -# Generated by Django 4.1.9 on 2023-09-19 12:40 | ||
2 | - | ||
3 | -from django.db import migrations | ||
4 | - | ||
5 | - | ||
6 | -class Migration(migrations.Migration): | ||
7 | - | ||
8 | - dependencies = [ | ||
9 | - ('edicto', '0015_edicto_usuario_movi'), | ||
10 | - ] | ||
11 | - | ||
12 | - operations = [ | ||
13 | - migrations.RenameField( | ||
14 | - model_name='edicto', | ||
15 | - old_name='usuario', | ||
16 | - new_name='creado_por', | ||
17 | - ), | ||
18 | - migrations.RenameField( | ||
19 | - model_name='edicto', | ||
20 | - old_name='usuario_movimiento', | ||
21 | - new_name='modificado_por', | ||
22 | - ), | ||
23 | - ] |
1 | +# Generated by Django 4.1.9 on 2023-09-19 13:29 | ||
2 | + | ||
3 | +from django.db import migrations, models | ||
4 | +import uuid | ||
5 | + | ||
6 | + | ||
7 | +class Migration(migrations.Migration): | ||
8 | + | ||
9 | + dependencies = [ | ||
10 | + ('edicto', '0016_remove_edicto_usuario_and_more'), | ||
11 | + ] | ||
12 | + | ||
13 | + operations = [ | ||
14 | + migrations.RemoveField( | ||
15 | + model_name='edicto', | ||
16 | + name='id', | ||
17 | + ), | ||
18 | + migrations.AlterField( | ||
19 | + model_name='edicto', | ||
20 | + name='uuid', | ||
21 | + field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True), | ||
22 | + ), | ||
23 | + ] |
1 | +# Generated by Django 4.1.9 on 2023-09-19 13:34 | ||
2 | + | ||
3 | +from django.db import migrations, models | ||
4 | + | ||
5 | + | ||
6 | +class Migration(migrations.Migration): | ||
7 | + | ||
8 | + dependencies = [ | ||
9 | + ('edicto', '0017_remove_edicto_id_alter_edicto_uuid'), | ||
10 | + ] | ||
11 | + | ||
12 | + operations = [ | ||
13 | + migrations.AlterField( | ||
14 | + model_name='edicto', | ||
15 | + name='fecha_modificacion', | ||
16 | + field=models.DateTimeField(auto_now=True), | ||
17 | + ), | ||
18 | + ] |
@@ -25,8 +25,8 @@ class Precio (models.Model): | @@ -25,8 +25,8 @@ class Precio (models.Model): | ||
25 | 25 | ||
26 | 26 | ||
27 | class Edicto(models.Model): | 27 | class Edicto(models.Model): |
28 | - uuid = models.UUIDField(unique=True, editable=False, default=uuid4) | ||
29 | - creado_por = models.ForeignKey(Usuario, on_delete=models.CASCADE, verbose_name='Usuario') | 28 | + uuid = models.UUIDField(unique=True, editable=False, default=uuid4, primary_key=True) |
29 | + creado_por = models.ForeignKey(Usuario, on_delete=models.CASCADE, verbose_name='Usuario', editable=False) | ||
30 | cuerpo_edicto = models.TextField(blank=False, null=False) | 30 | cuerpo_edicto = models.TextField(blank=False, null=False) |
31 | archivo = models.FileField(upload_to="uploads/%Y/%m/%d/", null=False, blank=False) | 31 | archivo = models.FileField(upload_to="uploads/%Y/%m/%d/", null=False, blank=False) |
32 | dias_publicar = models.PositiveIntegerField(blank=False, null=False) | 32 | dias_publicar = models.PositiveIntegerField(blank=False, null=False) |
@@ -36,9 +36,9 @@ class Edicto(models.Model): | @@ -36,9 +36,9 @@ class Edicto(models.Model): | ||
36 | cantidad_copias = models.PositiveIntegerField(blank=False, null=False) | 36 | cantidad_copias = models.PositiveIntegerField(blank=False, null=False) |
37 | fecha_publicacion = models.DateField(blank=True, null=True) | 37 | fecha_publicacion = models.DateField(blank=True, null=True) |
38 | observaciones = models.CharField(max_length=500, blank=True, null=True) | 38 | observaciones = models.CharField(max_length=500, blank=True, null=True) |
39 | - fecha_creacion = models.DateField(auto_now_add=True) | ||
40 | - fecha_modificacion = models.DateTimeField(auto_now_add=True) | ||
41 | - modificado_por = models.ForeignKey(Usuario, on_delete=models.CASCADE, related_name='udate_edicto') | 39 | + fecha_creacion = models.DateField(auto_now_add=True, editable=False) |
40 | + fecha_modificacion = models.DateTimeField(auto_now=True, editable=False) | ||
41 | + modificado_por = models.ForeignKey(Usuario, on_delete=models.CASCADE, related_name='udate_edicto', editable=False) | ||
42 | 42 | ||
43 | class Meta: | 43 | class Meta: |
44 | verbose_name = 'Edicto' | 44 | verbose_name = 'Edicto' |
@@ -32,10 +32,7 @@ class EdictoSerializer(serializers.ModelSerializer): | @@ -32,10 +32,7 @@ class EdictoSerializer(serializers.ModelSerializer): | ||
32 | 32 | ||
33 | ) | 33 | ) |
34 | 34 | ||
35 | - read_only_fields = ('creado_por', 'modificado_por', | ||
36 | - 'fecha_publicacion', 'cantidad_palabras', | ||
37 | - 'fecha_creacion', | ||
38 | - 'fecha_modificacion', | 35 | + read_only_fields = ('fecha_publicacion', 'cantidad_palabras', |
39 | ) | 36 | ) |
40 | 37 | ||
41 | def validate(self, data): | 38 | def validate(self, data): |
-
Please register or login to post a comment