diff --git a/django/contrib/admin/templates/admin/prepopulated_fields_js.html b/django/contrib/admin/templates/admin/prepopulated_fields_js.html
index 43ef5ba..7300bea 100644
a
|
b
|
|
| 1 | {% load l10n %} |
1 | 2 | <script type="text/javascript"> |
2 | 3 | (function($) { |
3 | 4 | var field = null; |
… |
… |
|
7 | 8 | id: '#{{ field.field.auto_id }}', |
8 | 9 | dependency_ids: [], |
9 | 10 | dependency_list: [], |
10 | | maxLength: {{ field.field.field.max_length|default_if_none:"50" }} |
| 11 | maxLength: {{ field.field.field.max_length|default_if_none:"50"|unlocalize }} |
11 | 12 | }; |
12 | 13 | |
13 | 14 | {% for dependency in field.dependencies %} |
diff --git a/tests/regressiontests/admin_views/models.py b/tests/regressiontests/admin_views/models.py
index 97f6708..3b7bea8 100644
a
|
b
|
class PrePopulatedSubPost(models.Model):
|
539 | 539 | subtitle = models.CharField(max_length=100) |
540 | 540 | subslug = models.SlugField() |
541 | 541 | |
| 542 | class PrePopulatedPostLargeSlug(models.Model): |
| 543 | """ |
| 544 | Regression test for #15938: a large max_length for the slugfield must not |
| 545 | be localized in prepopulated_fields_js.html or it might end up breaking |
| 546 | the javascript (ie, using THOUSAND_SEPARATOR ends up with maxLength=1,000) |
| 547 | """ |
| 548 | title = models.CharField(max_length=100) |
| 549 | published = models.BooleanField() |
| 550 | slug = models.SlugField(max_length=1000) |
| 551 | |
| 552 | class PrePopulatedPostLargeSlugAdmin(admin.ModelAdmin): |
| 553 | prepopulated_fields = { |
| 554 | 'slug' : ('title',) |
| 555 | } |
| 556 | |
542 | 557 | class SubPostInline(admin.TabularInline): |
543 | 558 | model = PrePopulatedSubPost |
544 | 559 | |
… |
… |
admin.site.register(Album, AlbumAdmin)
|
864 | 879 | admin.site.register(Question) |
865 | 880 | admin.site.register(Answer) |
866 | 881 | admin.site.register(PrePopulatedPost, PrePopulatedPostAdmin) |
| 882 | admin.site.register(PrePopulatedPostLargeSlug, PrePopulatedPostLargeSlugAdmin) |
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 0537160..1102d64 100644
a
|
b
|
class PrePopulatedTest(TestCase):
|
2614 | 2614 | self.assertNotContains(response, "field['dependency_ids'].push('#id_title');") |
2615 | 2615 | self.assertNotContains(response, "id: '#id_prepopulatedsubpost_set-0-subslug',") |
2616 | 2616 | |
| 2617 | def test_prepopulated_maxlength_localized(self): |
| 2618 | """ |
| 2619 | Regression test for #15938: if USE_THOUSAND_SEPARATOR is set, make sure |
| 2620 | that maxLength (in the javascript) is rendered without separators. |
| 2621 | """ |
| 2622 | self.old_USE_THOUSAND_SEPARATOR = settings.USE_THOUSAND_SEPARATOR |
| 2623 | self.old_USE_L10N = settings.USE_L10N |
| 2624 | settings.USE_THOUSAND_SEPARATOR = True |
| 2625 | settings.USE_L10N = True |
| 2626 | response = self.client.get('/test_admin/admin/admin_views/prepopulatedpostlargeslug/add/') |
| 2627 | self.assertContains(response, "maxLength: 1000") # instead of 1,000 |
| 2628 | |
| 2629 | |
2617 | 2630 | class ReadonlyTest(TestCase): |
2618 | 2631 | fixtures = ['admin-views-users.xml'] |
2619 | 2632 | |