#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
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak):

 We wanted to add `DatabaseDefault()` to the list of `Field.empty_values`
 and modify its `__hash__` and `__eq__`. Unfortunately, there is an issue
 in importing `DatabaseDefault` anywhere in the `forms` module and
 `expression` is required to initialize `DatabaseDefault`. I'm thinking
 about adding `is_value_empty()` hook to the `Field`:
 {{{#!python
 def is_value_empty(self, value):
     return value in self.empty_values or isinstance(value,
 DatabaseDefault):
 }}}
 and reusing it everywhere we currently check `if value in
 self.empty_values`.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/37168#comment:2>
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/0107019ec1bc306f-7d922fc0-4c80-4ccc-845e-4b1143ef462d-000000%40eu-central-1.amazonses.com.

Reply via email to