mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Fixed #29426 -- Made UUID inputs in the admin match the width of a UUID.
This commit is contained in:
parent
b042ab8976
commit
c832885a3e
@ -92,6 +92,7 @@ FORMFIELD_FOR_DBFIELD_DEFAULTS = {
|
|||||||
models.ImageField: {'widget': widgets.AdminFileWidget},
|
models.ImageField: {'widget': widgets.AdminFileWidget},
|
||||||
models.FileField: {'widget': widgets.AdminFileWidget},
|
models.FileField: {'widget': widgets.AdminFileWidget},
|
||||||
models.EmailField: {'widget': widgets.AdminEmailInputWidget},
|
models.EmailField: {'widget': widgets.AdminEmailInputWidget},
|
||||||
|
models.UUIDField: {'widget': widgets.AdminUUIDInputWidget},
|
||||||
}
|
}
|
||||||
|
|
||||||
csrf_protect_m = method_decorator(csrf_protect)
|
csrf_protect_m = method_decorator(csrf_protect)
|
||||||
|
@ -353,7 +353,7 @@ body.popup .submit-row {
|
|||||||
width: 2.2em;
|
width: 2.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vTextField {
|
.vTextField, .vUUIDField {
|
||||||
width: 20em;
|
width: 20em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,6 +351,11 @@ class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget):
|
|||||||
class_name = 'vBigIntegerField'
|
class_name = 'vBigIntegerField'
|
||||||
|
|
||||||
|
|
||||||
|
class AdminUUIDInputWidget(forms.TextInput):
|
||||||
|
def __init__(self, attrs=None):
|
||||||
|
super().__init__(attrs={'class': 'vUUIDField', **(attrs or {})})
|
||||||
|
|
||||||
|
|
||||||
# Mapping of lower case language codes [returned by Django's get_language()]
|
# Mapping of lower case language codes [returned by Django's get_language()]
|
||||||
# to language codes supported by select2.
|
# to language codes supported by select2.
|
||||||
# See django/contrib/admin/static/admin/js/vendor/select2/i18n/*
|
# See django/contrib/admin/static/admin/js/vendor/select2/i18n/*
|
||||||
|
@ -408,6 +408,20 @@ class AdminURLWidgetTest(SimpleTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class AdminUUIDWidgetTests(SimpleTestCase):
|
||||||
|
def test_attrs(self):
|
||||||
|
w = widgets.AdminUUIDInputWidget()
|
||||||
|
self.assertHTMLEqual(
|
||||||
|
w.render('test', '550e8400-e29b-41d4-a716-446655440000'),
|
||||||
|
'<input value="550e8400-e29b-41d4-a716-446655440000" type="text" class="vUUIDField" name="test">',
|
||||||
|
)
|
||||||
|
w = widgets.AdminUUIDInputWidget(attrs={'class': 'myUUIDInput'})
|
||||||
|
self.assertHTMLEqual(
|
||||||
|
w.render('test', '550e8400-e29b-41d4-a716-446655440000'),
|
||||||
|
'<input value="550e8400-e29b-41d4-a716-446655440000" type="text" class="myUUIDInput" name="test">',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@override_settings(ROOT_URLCONF='admin_widgets.urls')
|
@override_settings(ROOT_URLCONF='admin_widgets.urls')
|
||||||
class AdminFileWidgetTests(TestDataMixin, TestCase):
|
class AdminFileWidgetTests(TestDataMixin, TestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user