#26080: Missing field.on_delete
----------------------------------------------+--------------------
Reporter: srkunze | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Database layer (models, ORM) | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
We still upgrade from 1.7 to 1.8 and replace all legacy API with
get_fields().
Please consider the following loop:
{{{
for field in User._meta.get_fields():
if not field.is_relation:
continue
if field.on_delete != models.CASCADE:
continue
# do what's necessary
}}}
We've noticed field has not on_delete in all cases.
Wouldn't it make sense to have an {{{ on_delete }}} attribute always
available all the time **if the field is a relation** (even if it's None)?
Right now, we need to check for {{{ hasattr(field, 'on_delete') }}}.
--
Ticket URL: <https://code.djangoproject.com/ticket/26080>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.926ddeb82ac691561067067224e5e6eb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.