Re: How to check for m2m orphans before deleting an object?

2010-08-14 Thread Alessandro Pasotti
2010/8/13 Nick Serra > Look into the clear() method on many to many relations. > Calling .clear() before a delete will remove all relations between the > models and allow you to delete the category only. You might be > fighting the django admin on this though, so this would

Re: How to check for m2m orphans before deleting an object?

2010-08-13 Thread Nick Serra
Look into the clear() method on many to many relations. Calling .clear() before a delete will remove all relations between the models and allow you to delete the category only. You might be fighting the django admin on this though, so this would be best implemented in a custom solution. Not sure

Re: How to check for m2m orphans before deleting an object?

2010-08-13 Thread Alessandro Pasotti
2010/8/13 cootetom > Hi, as far as i'm aware, the delete method on models only get's called > if you delete an instance of that modal directly. So if you delete a > modal who has many children, the child delete methods don't get > called. So I suppose the next question would

Re: How to check for m2m orphans before deleting an object?

2010-08-13 Thread cootetom
Hi, as far as i'm aware, the delete method on models only get's called if you delete an instance of that modal directly. So if you delete a modal who has many children, the child delete methods don't get called. So I suppose the next question would be are you deleting TrackCategory's directly or

How to check for m2m orphans before deleting an object?

2010-08-13 Thread Alessandro Pasotti
Hi, I have a m2m like this: class TrackCategory(Model): class Track(Model): category = models.ManyToManyField(TrackCategory) I want to avoid that users delete a TrackCategory which contains Tracks, the best would be to allow deletion of the TrackCategory if and only the linked Tracks