Previously accidentally posted to the Django users group instead of 
here. Sorry!



http://code.djangoproject.com/ticket/7539 suggests a way to add On
Delete and On Update support to Django foreign key fields, and includes
a patch that implements the suggestions. At the time I submitted it,
getting Django 1.1 out the door prevented it from being seriously
considered, but now that 1.2 is in the planning stages, how about it?

The ticket actually suggests several changes:

1) Adding an on_delete parameter to ForeignKey definitions and allowing
it to specify CASCADE, SET_NULL, or RESTRICT behavior.

2) Modifying Django's built-in behavior, which currently always cascades
deletes, to handle the new SET_NULL and RESTRICT behaviors. Django still
defaults to CASCADE behavior for foreign keys that don't specify an
on_delete parameter.

3) Allowing settings files to change the default on delete behavior from
CASCADE to one of the other options for foreign keys that don't specify
an on_delete parameter.

4) Allowing settings files to specify that the on_delete behavior should
be handled by the database backend rather than by Django, and changing
the SQL generated by Django to contain appropriate ON DELETE clauses.

5) Adding an on_update parameter to ForeignKey definitions. Unlike the
on_delete parameter, the patch doesn't implement built-in emulation of
on_update: on_update clauses are only handled by the database backend.


I believe that items 1-3 are in a form that is usable with little
modification, and would like to suggest that at least this much be added
to 1.2.

Items 4 and 5 would need more work to support more back ends before it
makes sense to include them.

It might also be nice to have an implementation of item 5 that doesn't
depend on the db backend, although this might require a significant
amount of work.





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to