#10057: ModelAdmin.render_change_form should not override the 'has_delete'
option
-------------------------------------------+--------------------------------
Reporter: rajeesh | Owner: nobody
Status: new | Milestone: post-1.0
Component: django.contrib.admin | Version: SVN
Keywords: ModelAdmin render_change_form | Stage: Unreviewed
Has_patch: 1 |
-------------------------------------------+--------------------------------
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
--
Ticket URL: <http://code.djangoproject.com/ticket/10057>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---