hmm, I found the answers
1. use a pre_delete signal instead of overwrite the model's and
queryset's delete methods
2. use a specific exception subclass and catch it int the view
Am I correct?

On 26. Aug, 11:45 h., gentlestone <tibor.b...@hotmail.com> wrote:
> Because of Django CASCADE ON DELETE behavior I want to refuse deletion
> of the object with related objects. I overwrote my del method in the
> model:
>
>     def delete(self):
>         "Allow only if there are no related objects"
>         seen_objs = CollectedObjects()
>         self._collect_sub_objects(seen_objs)
>         if len(seen_objs.items()) > 1:
>             raise Exception("This instance has related objects!")
>         super(MyModel, self).delete()
>
> The manager's delete method does'nt call the object's delete method.
> So I have to rewrote the manager's delete method also.
>
> But this is not DRY.
>
> What is the correct solution?
> How can I propagate the  Exception("The signature has related
> objects!") to HTML? Because ugettext_lazy("The signature has related
> objects!") does'nt works.
--~--~---------~--~----~------------~-------~--~----~
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 
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