#30436: ForeignKey on_delete parameter should be validated
-----------------------------------------+------------------------
               Reporter:  Rémy Hubscher  |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  2.2
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 If you set `on_delete=None` as a ForeignKey field parameter you might get
 the following error:

 {{{
   File "django/contrib/admin/options.py", line 1823, in
 get_deleted_objects
     return get_deleted_objects(objs, request, self.admin_site)
   File "django/contrib/admin/utils.py", line 134, in get_deleted_objects
     collector.collect(objs)
   File "django/contrib/admin/utils.py", line 197, in collect
     return super().collect(objs, source_attr=source_attr, **kwargs)
   File "django/db/models/deletion.py", line 221, in collect
     field.remote_field.on_delete(self, field, sub_objs, self.using)

 TypeError: 'NoneType' object is not callable
 }}}

 I believe that we could validate the on_delete value to prevent such
 behaviour. Or at least tell that None is not a valid on_delete value.

 Refs
 
https://docs.djangoproject.com/fr/2.2/ref/models/fields/#django.db.models.ForeignKey.on_delete

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30436>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/048.36e00cef2a2586884c6aced7b6bf3536%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to