Hello,

here is a "simple" way to achieve conditional hiding of the submit row:

1) make a copy of django\contrib\admin\templates\admin\change_form.html
    in your own template: location
mytemplates\admin_copies\change_form.html

2) change it by wrapping submit_row in a block, for example:
   {% block hidesubmit %}{% submit_row %}{% endblock %}

3) create a new change_form.html template in mytemplates\admin\ to
extend the admin copy:

{% extends "admin_copies/change_form.html" %}
{% load i18n admin_modify adminmedia %}
{% block hidesavetop %}
  {% include "admin_lib/hidesave.html" %}
{% endblock %}
{% block hidesavebot %}
  {% include "admin_lib/hidesave.html" %}
{% endblock %}

4) create mytemplates\admin_lib\hidesave.html:

{% load i18n admin_modify adminmedia %}
{% ifequal user.username 'admin' %}
  {% submit_row %}
{% else %}
      {% if original.admin.all %}
        {% for a in original.admin.all %}
          {% ifequal user.username a.user.username %}
            {% submit_row %}
          {% endifequal %}
        {% endfor %}
      {% else %}
        {% submit_row %}
      {% endif %}
{% endifequal %}


Notes:
- here I have only one administrator named admin. It should be possible
to improve this template to make it more generic.
- this also assume that the model provides an admin field which is a
ManytoMany (or ForeignKey) to Django User model. Maybe there is way to
detect which field is related to User model.

HTH

Olive.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to