In one of my Django projects, customer accidentally deleted related
objects because django-batchadmin doesn't advice for related objects
deletion. The question was I thought Django would not delete related
objects in a nullable many to one relation, but Django in fact deleted
it (of course, according to documentation).
Customer uses admin for site administration and I think is not usable
that in a usual object -> category nullable relation he have to clear
every object related to one category (maybe hundreds of them) to
remove the category itself.
Then, I searched into docs and internet for a solution to my problem,
and the options were:
1) Use a many to many relation. This is not viable... ¿why I have to
change a good data model into a not real model to get it work? In UML
there are two kinds of many to one relations: aggregations and
compositions. Objects in a aggregation can exists independently of his
parent object.
2) Clear related objects before deleting (with objects.clear() ), but
it doesn't work for a default django admin site.
These are the reasons to think in a possible improvement in Django
ORM. I've patched django to support a model like this:
class Master(models.Model):
pass
class Slave(models.Model):
master = models.ForeignKey(Master, null=True, delete_cascade=False)
Independently in notation i've used, I think this concept can be
useful in a lot of Django web sites.
I've created a ticket for this and attached a patch with unit tests.
This ticket was marked into "Design decision needed" stage by a
triager, and this is the reason I post this.
Ticket is this:
http://code.djangoproject.com/ticket/10262
If other developers accept this ticket (maybe with another notation),
I compromise to work on this.
Regards,
Manuel Saelices
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---