#37168: Readonly fields with db_default display DatabaseDefault representation
-------------------------------------+-------------------------------------
     Reporter:  Mariusz Felisiak     |                    Owner:  Mariusz
                                     |  Felisiak
         Type:  Bug                  |                   Status:  assigned
    Component:  Forms                |                  Version:  6.0
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by Mariusz Felisiak:

Old description:

> Readonly fields with `db_default` display `DatabaseDefault()`
> representation in the admin. For example:
>
> - `models.py`
> {{{#!python
> class MyModel(models.Model):
>     uuid = models.UUIDField(db_default=UUID7(), editable=False,
> primary_key=True)
>     created_datetime = models.DateTimeField(db_default=Now(),
> editable=False)
>     modified_datetime = models.DateTimeField(db_default=Now(),
> editable=False)
>     name = models.TextField()
> }}}
>
> - `admin.py`
>
> {{{#!python
> @admin.register(MyModel)
> class MyModelAdmin(admin.ModelAdmin):
>     readonly_fields = ["uuid", "created_datetime", "modified_datetime"]
> }}}
>

> I think they should be consider as any other empty values.

New description:

 Readonly fields with `db_default` display `DatabaseDefault()`
 representation in the admin. For example:

 - `models.py`
 {{{#!python
 class MyModel(models.Model):
     uuid = models.UUIDField(db_default=UUID7(), editable=False,
 primary_key=True)
     created_datetime = models.DateTimeField(db_default=Now(),
 editable=False)
     modified_datetime = models.DateTimeField(db_default=Now(),
 editable=False)
     name = models.TextField()
 }}}

 - `admin.py`

 {{{#!python
 @admin.register(MyModel)
 class MyModelAdmin(admin.ModelAdmin):
     readonly_fields = ["uuid", "created_datetime", "modified_datetime"]
 }}}

 [[Image(Screenshot_20260613_125111.png​)]]
 I think they should be consider as any other empty values.

--
-- 
Ticket URL: <https://code.djangoproject.com/ticket/37168#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019ec09c82e0-890881db-d825-40d5-948e-5f1552277af1-000000%40eu-central-1.amazonses.com.

Reply via email to