mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 11:04:02 +03:00
Refactor get_field_info method to include max_digits and decimal_places attributes in SimpleMetadata class (#8943)
* Refactor get_field_info method to include max_digits and decimal_places attributes in SimpleMetadata class * Add new test to check decimal_field_info_type * Update rest_framework/metadata.py --------- Co-authored-by: Mahdi <mahdi@Mahdis-MacBook-Pro.local> Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
This commit is contained in:
parent
38a74b42da
commit
1ce0853ac5
|
@ -124,7 +124,8 @@ class SimpleMetadata(BaseMetadata):
|
||||||
attrs = [
|
attrs = [
|
||||||
'read_only', 'label', 'help_text',
|
'read_only', 'label', 'help_text',
|
||||||
'min_length', 'max_length',
|
'min_length', 'max_length',
|
||||||
'min_value', 'max_value'
|
'min_value', 'max_value',
|
||||||
|
'max_digits', 'decimal_places'
|
||||||
]
|
]
|
||||||
|
|
||||||
for attr in attrs:
|
for attr in attrs:
|
||||||
|
|
|
@ -324,6 +324,13 @@ class TestSimpleMetadataFieldInfo(TestCase):
|
||||||
)
|
)
|
||||||
assert 'choices' not in field_info
|
assert 'choices' not in field_info
|
||||||
|
|
||||||
|
def test_decimal_field_info_type(self):
|
||||||
|
options = metadata.SimpleMetadata()
|
||||||
|
field_info = options.get_field_info(serializers.DecimalField(max_digits=18, decimal_places=4))
|
||||||
|
assert field_info['type'] == 'decimal'
|
||||||
|
assert field_info['max_digits'] == 18
|
||||||
|
assert field_info['decimal_places'] == 4
|
||||||
|
|
||||||
|
|
||||||
class TestModelSerializerMetadata(TestCase):
|
class TestModelSerializerMetadata(TestCase):
|
||||||
def test_read_only_primary_key_related_field(self):
|
def test_read_only_primary_key_related_field(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user