Skip to content

Commit

Permalink
Added "allow_unicode" to generated kwargs for ModelSerializer SlugFie…
Browse files Browse the repository at this point in the history
…ld (#6315)
  • Loading branch information
naihe2010 authored and carltongibson committed Dec 19, 2018
1 parent 7ad5bdb commit 963ce30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions rest_framework/utils/field_mapping.py
Expand Up @@ -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'}

Expand Down
2 changes: 1 addition & 1 deletion tests/test_model_serializer.py
Expand Up @@ -183,7 +183,7 @@ class Meta:
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)
Expand Down

0 comments on commit 963ce30

Please sign in to comment.