﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
10057	ModelAdmin.render_change_form should not override the 'has_delete' option	rajeesh	nobody	"The methods, add_view and change_view in class ModelAdmin in options.py, call another method, render_change_form, to display the add and edit forms respectively. The add_view passes it a context dictionary which includes a 'has_delete' option which in turn makes the 'Delete' button invisible from the add form. When I wanted to make the Delete button invisible from the edit form also (based on specific conditions), I hoped a similar approach in change_view, that is, including 'has_delete' option may help the cause. But render_change_form seems to ignore that option explained below:

{{
def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None): 
    #few lines here
    context.update({
        #few_other_options_here
        ################################################################
        'has_delete_permission': self.has_delete_permission(request, obj)
        ################################################################
        # The above line is what overrides the has_delete option passed!
   #more code here
}}

Changing the above mentioned line to
 
{{ 'has_delete_permission': context.get('show_delete',True) and \
                        self.has_delete_permission(request, obj) 
}}

 may solve the problem. By this way, the developer can decide when to make the Delete button visible just by passing an extra context option, 'has_delete' to the change_view.

Looking forward to alternative suggestions and comments"		new	contrib.admin	dev			ModelAdmin render_change_form		Unreviewed	1	0	0	0		
