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 if you could override
delete and call the clear() function, this may trick the admin into
keeping the related objects, or maybe do something in a pre_delete
signal. Check out the clear function here:
http://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward

On Aug 13, 11:33 am, Alessandro Pasotti <apaso...@gmail.com> wrote:
> 2010/8/13 cootetom <coote...@gmail.com>
>
> > 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 are you deleting something that contains
> > TrackCategory's?
>
> In my test I'm deleting the category directly from the admin panel.
>
> But the other case is also possible because TrackCategories can be nested in
> a tree with MPTT (code.google.com/p/django-mptt/), perhaps this app override
> delete() ?
>
> In my test the TrackCategory I'm deleting has no subcategories and has no
> parent category.
>
> --
> Alessandro Pasotti
> w3:  www.itopen.it

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

Reply via email to