mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 08:29:59 +03:00
Fixed URLField not retrieving the max_length attribute from a ModelField
This commit is contained in:
parent
4e80541824
commit
d0e9a74383
|
@ -531,6 +531,10 @@ class ModelSerializer(Serializer):
|
|||
if issubclass(model_field.__class__, models.TextField):
|
||||
kwargs['widget'] = widgets.Textarea
|
||||
|
||||
# URLField not getting correct max_length kwarg
|
||||
if issubclass(model_field.__class__, models.URLField):
|
||||
kwargs['max_length'] = model_field.max_length
|
||||
|
||||
# TODO: TypedChoiceField?
|
||||
if model_field.flatchoices: # This ModelField contains choices
|
||||
kwargs['choices'] = model_field.flatchoices
|
||||
|
|
Loading…
Reference in New Issue
Block a user