Added "allow_unicode" to generated kwargs for ModelSerializer SlugField (#6315)

This commit is contained in:
Alf 2018-12-19 22:37:52 +08:00 committed by Carlton Gibson
parent 7ad5bdb669
commit 963ce306f3
2 changed files with 4 additions and 1 deletions

View File

@ -88,6 +88,9 @@ def get_field_kwargs(field_name, model_field):
if decimal_places is not None:
kwargs['decimal_places'] = decimal_places
if isinstance(model_field, models.SlugField):
kwargs['allow_unicode'] = model_field.allow_unicode
if isinstance(model_field, models.TextField) or (postgres_fields and isinstance(model_field, postgres_fields.JSONField)):
kwargs['style'] = {'base_template': 'textarea.html'}

View File

@ -183,7 +183,7 @@ class TestRegularFieldMappings(TestCase):
null_boolean_field = NullBooleanField(required=False)
positive_integer_field = IntegerField()
positive_small_integer_field = IntegerField()
slug_field = SlugField(max_length=100)
slug_field = SlugField(allow_unicode=False, max_length=100)
small_integer_field = IntegerField()
text_field = CharField(max_length=100, style={'base_template': 'textarea.html'})
file_field = FileField(max_length=100)