mohan wrote:
> Hi,
> 
> I have the following 3 models with one model having a foreign key
> reference to another model.
> 
> class DeliveryBatch(models.Model):
>     delivered_to = models.ForeignKey(Centre)
>     ...
> 
> class Centre(models.Model):
>     is_deleted  = models.BooleanField(default=false)
>     ...
> 
> class CentreLog(models.Model):
>    """contains all attributes of Centre together with
> last_modified_time, user and corresponding action."""
>     ...
> 
> The problem is, a Centre referred to by a DeliveryBatch may get deleted
> in the future. Then the foreign key reference of the DeliveryBatch gets
> invalid. Django even goes a step further and deletes the corresponding
> DeliveryBatch. But this is undesirable.

The usual approach is to set delivered_to to NULL (or, None)
before deleting it.

Michael


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to