Ticket #19888: 0001-PoC-for-19888-fix.patch

File 0001-PoC-for-19888-fix.patch, 2.0 KB (added by nickname123, 12 years ago)
  • django/contrib/admin/helpers.py

    From 3891935d21ca940456e2e9e9ea8f3bf5b6345a01 Mon Sep 17 00:00:00 2001
    From: gordon <wgordonw1@gmail.com>
    Date: Sat, 23 Feb 2013 18:08:08 -0500
    Subject: [PATCH] PoC for #19888 fix
    
    ---
     django/contrib/admin/helpers.py                               | 3 +++
     django/contrib/admin/templates/admin/edit_inline/tabular.html | 7 +++++++
     2 files changed, 10 insertions(+)
    
    diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py
    index 4203287..2a747c2 100644
    a b class InlineAdminForm(AdminForm):  
    289289    def pk_field(self):
    290290        return AdminField(self.form, self.formset._pk_field.name, False)
    291291
     292    def pk_field_name(self):
     293        return self.formset._pk_field.name
     294
    292295    def fk_field(self):
    293296        fk = getattr(self.formset, "fk", None)
    294297        if fk:
  • django/contrib/admin/templates/admin/edit_inline/tabular.html

    diff --git a/django/contrib/admin/templates/admin/edit_inline/tabular.html b/django/contrib/admin/templates/admin/edit_inline/tabular.html
    index 71a62ba..5541432 100644
    a b  
    4747              <td{% if field.field.name %} class="field-{{ field.field.name }}"{% endif %}>
    4848              {% if field.is_readonly %}
    4949                  <p>{{ field.contents|linebreaksbr }}</p>
     50                  {% if inline_admin_form.pk_field_name == field.field.name %}
     51                    <input type="hidden"
     52                           value="{{ field.contents }}"
     53                           id="id_{{ inline_admin_form.formset.prefix }}-{{ forloop.parentloop.parentloop.parentloop.counter0 }}-{{ field.field.name }}"
     54                           name="{{ inline_admin_form.formset.prefix }}-{{ forloop.parentloop.parentloop.parentloop.counter0 }}-{{ field.field.name }}"
     55                           readonly />
     56                  {% endif %}
    5057              {% else %}
    5158                  {{ field.field.errors.as_ul }}
    5259                  {{ field.field }}
Back to Top