diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py
index b90f5ec..6ca2941 100644
a
|
b
|
|
1 | 1 | from django import forms |
2 | 2 | from django.conf import settings |
3 | 3 | from django.contrib.admin.util import flatten_fieldsets, lookup_field |
4 | | from django.contrib.admin.util import display_for_field, label_for_field |
| 4 | from django.contrib.admin.util import display_for_field, label_for_field, help_text_for_field |
5 | 5 | from django.contrib.contenttypes.models import ContentType |
6 | 6 | from django.core.exceptions import ObjectDoesNotExist |
7 | 7 | from django.db.models.fields.related import ManyToManyRel |
… |
… |
class AdminReadonlyField(object):
|
140 | 140 | class_name = field.__name__ != '<lambda>' and field.__name__ or '' |
141 | 141 | else: |
142 | 142 | class_name = field |
| 143 | |
143 | 144 | self.field = { |
144 | 145 | 'name': class_name, |
145 | 146 | 'label': label, |
146 | 147 | 'field': field, |
| 148 | 'help_text': help_text_for_field(class_name, form._meta.model) |
147 | 149 | } |
| 150 | |
148 | 151 | self.form = form |
149 | 152 | self.model_admin = model_admin |
150 | 153 | self.is_first = is_first |
151 | 154 | self.is_checkbox = False |
152 | 155 | self.is_readonly = True |
| 156 | self.help_text = help_text_for_field(class_name, form._meta.model) |
153 | 157 | |
154 | 158 | def label_tag(self): |
155 | 159 | attrs = {} |
diff --git a/django/contrib/admin/templates/admin/includes/fieldset.html b/django/contrib/admin/templates/admin/includes/fieldset.html
index addfd08..6363aee 100644
a
|
b
|
|
19 | 19 | {{ field.field }} |
20 | 20 | {% endif %} |
21 | 21 | {% endif %} |
22 | | {% if field.field.field.help_text %} |
23 | | <p class="help">{{ field.field.field.help_text|safe }}</p> |
| 22 | {% if field.field.help_text %} |
| 23 | <p class="help">{{ field.field.help_text|safe }}</p> |
24 | 24 | {% endif %} |
25 | 25 | </div> |
26 | 26 | {% endfor %} |
diff --git a/django/contrib/admin/util.py b/django/contrib/admin/util.py
index 1c39614..d3f17d6 100644
a
|
b
|
def label_for_field(name, model, model_admin=None, return_attr=False):
|
266 | 266 | else: |
267 | 267 | return label |
268 | 268 | |
| 269 | def help_text_for_field(name, model): |
| 270 | try: |
| 271 | help_text = model._meta.get_field_by_name(name)[0].help_text |
| 272 | except models.FieldDoesNotExist: |
| 273 | help_text = "" |
| 274 | return smart_unicode(help_text) |
| 275 | |
269 | 276 | |
270 | 277 | def display_for_field(value, field): |
271 | 278 | from django.contrib.admin.templatetags.admin_list import _boolean_icon |
diff --git a/tests/regressiontests/admin_views/models.py b/tests/regressiontests/admin_views/models.py
index e64f713..6c40cf4 100644
a
|
b
|
class LinkInline(admin.TabularInline):
|
495 | 495 | class Post(models.Model): |
496 | 496 | title = models.CharField(max_length=100) |
497 | 497 | content = models.TextField() |
498 | | posted = models.DateField(default=datetime.date.today) |
| 498 | posted = models.DateField( |
| 499 | default=datetime.date.today, |
| 500 | help_text="Date post was posted and some unicode: ŠĐĆŽćžšđ" |
| 501 | ) |
499 | 502 | public = models.NullBooleanField() |
500 | 503 | |
501 | 504 | def awesomeness_level(self): |
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 661954c..13d1d13 100644
a
|
b
|
class ReadonlyTest(TestCase):
|
2308 | 2308 | self.assertContains(response, '<div class="form-row posted">') |
2309 | 2309 | self.assertContains(response, '<div class="form-row value">') |
2310 | 2310 | self.assertContains(response, '<div class="form-row ">') |
| 2311 | self.assertContains(response, 'Date post was posted and some unicode: ŠĐĆŽćžšđ') |
2311 | 2312 | |
2312 | 2313 | p = Post.objects.create(title="I worked on readonly_fields", content="Its good stuff") |
2313 | 2314 | response = self.client.get('/test_admin/admin/admin_views/post/%d/' % p.pk) |