Changes between Initial Version and Version 1 of Ticket #10057


Ignore:
Timestamp:
Jan 17, 2009, 2:22:29 PM (16 years ago)
Author:
Ramiro Morales
Comment:

(edited description to make it legible, next time please use the Preview button)

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #10057 – Description

    initial v1  
    11The 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:
    22
    3 {{
     3{{{
    44def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None):
    55    #few lines here
     
    1111        # The above line is what overrides the has_delete option passed!
    1212   #more code here
    13 }}
     13}}}
    1414
    1515Changing the above mentioned line to
    1616 
    17 {{ 'has_delete_permission': context.get('show_delete',True) and \
     17{{{
     18'has_delete_permission': context.get('show_delete',True) and \
    1819                        self.has_delete_permission(request, obj)
    19 }}
     20}}}
    2021
    2122 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.
Back to Top