class ReadOnlyAdminMixin(object): """Disables all editing capabilities.""" change_form_template = "admin/view.html" def __init__(self, *args, **kwargs): super(ReadOnlyAdminMixin, self).__init__(*args, **kwargs) self.readonly_fields = self.model._meta.get_all_field_names() def get_actions(self, request): actions = super(ReadOnlyAdminMixin, self).get_actions(request) del actions["delete_selected"] return actions def has_add_permission(self, request): return False def has_delete_permission(self, request, obj=None): return False def save_model(self, request, obj, form, change): pass def delete_model(self, request, obj): pass def save_related(self, request, form, formsets, change): pass # templates/admin/view.html {% extends "admin/change_form.html" %} {% load i18n %} {% block submit_buttons_bottom %}
{% endblock %} # templates/admin/view.html (for Grappelli) {% extends "admin/change_form.html" %} {% load i18n %} {% block submit_buttons_bottom %} {% endblock %}