#35676: ExclusionConstraint that includes a ForeignKey fails validation in
ModelForm
------------------------------+------------------------------------
Reporter: Take Weiland | Owner: (none)
Type: Bug | Status: new
Component: Forms | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Comment (by Take Weiland):
Yes, that definitely does seem sensible.
The only potential issue might be that when creating new objects then the
foreign key field will still be None, because the related object isn't
saved to the DB yet.
In my crude hack to work around this (override
`Model.validate_constraints` and remove the field from `exclude`) this
works fine, however I don't know if there are situations where it doesn't.
In my case (shown above) it will result in a `qs.filter(config=None)` to
happen. As I understand it, this doesn't do anything, but lookups other
than `exact` might not like a `None` there.
--
Ticket URL: <https://code.djangoproject.com/ticket/35676#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 on the web visit
https://groups.google.com/d/msgid/django-updates/010701914cd99ed7-449701a5-120c-42d0-a46e-240422bdbe27-000000%40eu-central-1.amazonses.com.