Ticket #14355: patch.4.diff

File patch.4.diff, 2.8 KB (added by Yeago, 14 years ago)

removed exception

  • contrib/admin/util.py

     
    312312    else:
    313313        return label
    314314
     315def help_text_for_field(name, model):
     316    return model._meta.get_field_by_name(name)[0].help_text
    315317
    316318def display_for_field(value, field):
    317319    from django.contrib.admin.templatetags.admin_list import _boolean_icon
  • contrib/admin/helpers.py

     
    11from django import forms
    22from django.conf import settings
    33from django.contrib.admin.util import flatten_fieldsets, lookup_field
    4 from django.contrib.admin.util import display_for_field, label_for_field
     4from django.contrib.admin.util import display_for_field, label_for_field, help_text_for_field
    55from django.contrib.contenttypes.models import ContentType
    66from django.core.exceptions import ObjectDoesNotExist
    77from django.db.models.fields import FieldDoesNotExist
     
    138138            class_name = field.__name__ != '<lambda>' and field.__name__ or ''
    139139        else:
    140140            class_name = field
     141
    141142        self.field = {
    142143            'name': class_name,
    143144            'label': label,
    144145            'field': field,
     146                        'help_text': help_text_for_field(class_name, form._meta.model)
    145147        }
     148
    146149        self.form = form
    147150        self.model_admin = model_admin
    148151        self.is_first = is_first
    149152        self.is_checkbox = False
    150153        self.is_readonly = True
     154        self.help_text = help_text_for_field(class_name, form._meta.model)
    151155
    152156    def label_tag(self):
    153157        attrs = {}
  • contrib/admin/templates/admin/includes/fieldset.html

     
    1313                    {% else %}
    1414                        {{ field.label_tag }}
    1515                        {% if field.is_readonly %}
    16                             <p>{{ field.contents }}</p>
     16                        <p>{{ field.contents }}</p>
    1717                        {% else %}
    1818                            {{ field.field }}
    1919                        {% endif %}
     20                        {% endif %}
     21                    {% if field.field.help_text %}
     22                        <p class="help">{{ field.field.help_text|safe }}</p>
    2023                    {% endif %}
    21                     {% if field.field.field.help_text %}
    22                         <p class="help">{{ field.field.field.help_text|safe }}</p>
    23                     {% endif %}
    2424                </div>
    2525            {% endfor %}
    2626        </div>
Back to Top