Jorge, thank you very much! Both for the detailed explanation and for the time you spent answering. I'll surely follow your guidelines for the "clean" solution.
Jorge Gajon wrote: > On 12/9/06, Mario Graziosi <[EMAIL PROTECTED]> wrote: > >> Is it possible to restrict the list of "would be deleted" objects when >> asking to delete a specific object using the admin interface? >> >> I have several thousand records related to the object to be deleted. Is >> is quite useless (and time consuming) to display the list of 3000+ >> records to ask for confirmation. It would suffice to just say "and >> other 3000+ objects of type XXX will be deleted... want confirm?" >> >> Even if I change the delete_confirmation form and comment-out the >> "deleted_objects|unordered_list" the Django admin interface takes a lot >> of time to read the "would-be-deleted" records. >> >> Does anyone know if there's an easy out-of-the-box way of doing it? >> >> > > I'm not sure if there is an out-of-the-box solution, but I'm guessing > there's not. > > The easiest but not cleanest solution is to modify the delete_stage() > view in the admin code so that it does not build up the list of > objects. The file is 'django/contrib/admin/views/main.py' at around > line number 488. > > The "clean" solution would be to create a custom delete_stage() view > in your project and capture the delete url so that you call your > custom view. > > For example, if your application is called 'myapp' and your model is > called 'mymodel', you would create the following entry in your url > patterns: > > ('^admin/myapp/mymodel/(.+)/delete/$', > 'myproject.myapp.views.delete_stage'), > > Then you create the delete_stage() view in your myapp/views.py file. > Since you only want to modify the current behavior, you can copy the > code from the "django/contrib/admin/views/main.py" file. > > The 'app_label' and 'model_name' parameters would be removed since > they are no longer captured in the url pattern. You would need to > change some things in the code, but it is very easy to figure it out, > just take a close look at the necessary imports that you'll need. > > The _get_deleted_objects() call is the one that takes a long time to > compute. You can safely remove it. > > Hope it helps. > > Regards, > Jorge > > > > > -- Mario Graziosi, mailto:[EMAIL PROTECTED] FG&A srl (http://www.fgasoftware.com/) [EMAIL PROTECTED]: The agile PBX (http://www.voiceatwork.eu/) Tel: 02 9350-4780 interno 101, Fax: 02 9139-0172 --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---