#36296: Constraint validation of models with generated fields using Q crashes 
with
AttributeError: 'Q' object has no attribute 'replace_expressions'
-------------------------------------+-------------------------------------
     Reporter:  David Sanders        |                    Owner:  (none)
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  5.2
  (models, ORM)                      |
     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 Simon Charette):

 This relates to #34871 which has
 [https://github.com/django/django/pull/19190/ a working prototype] that
 implements `Q.replace_expressions`.

 Note that passing a `Q` to `GeneratedFied.expression` was never entirely
 supported #34805 (as it's not an expression per-se) and passing a lookup
 instead most likely solves your issue

 {{{#!python
 is_buzz = models.GeneratedField(
      expression=Exact(F("bar"), Value("buzz")),
     output_field=models.BooleanField(),
     db_persist=True,
 )
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36296#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/01070195fbe82c06-6f508265-ec3c-4b2e-a7f5-43a78713e677-000000%40eu-central-1.amazonses.com.

Reply via email to