﻿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
22987	view only implementation (without using read only fields)	liwee_ong@…	nobody	"Initially, I started using read only fields for my project but it didn't work well with reversion. So I thought of another way to implement view only.

Required setup:
1. Disable enter key (via JS hack in base.html)
2. Hack change_form.html, add new variable 
{{{
        {% if enable_submit|default_if_none:True %}
            {% block submit_buttons_bottom %}{% submit_row %}{% endblock %}
        {% endif %}
}}}


Implementation: in admin.py, override add_view/change_view as needed, e.g.

{{{
    def change_view(self, request, object_id, form_url='', extra_context=None):
        extra_context = extra_context or {}            
        extra_context[""enable_submit""] = True        
        if YOUR_CONDITION_FOR_READ_ONLY: extra_context[""enable_submit""] = False
        
        return super(YOUR_CLASS_NAME, self).change_view(request, object_id, form_url, extra_context=extra_context)
}}}

"	New feature	closed	contrib.admin	1.6	Normal	duplicate	view, read_only, admin		Unreviewed	0	0	0	0	0	0
