mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 04:50:12 +03:00
Merge 26eb7c786b
into 99382f3ccb
This commit is contained in:
commit
ae534f8992
|
@ -788,6 +788,18 @@ class RegexField(CharField):
|
||||||
validator = RegexValidator(regex, message=self.error_messages['invalid'])
|
validator = RegexValidator(regex, message=self.error_messages['invalid'])
|
||||||
self.validators.append(validator)
|
self.validators.append(validator)
|
||||||
|
|
||||||
|
def __deepcopy__(self, memo):
|
||||||
|
# Handling case when regex is not passed in kwargs.
|
||||||
|
args = self._args[:1] + copy.deepcopy(self._args[1:])
|
||||||
|
kwargs = dict(self._kwargs)
|
||||||
|
|
||||||
|
# deepcopy doesn't work on compiled regex pattern
|
||||||
|
regex = kwargs.pop('regex', None)
|
||||||
|
kwargs = copy.deepcopy(kwargs)
|
||||||
|
if regex is not None:
|
||||||
|
kwargs['regex'] = regex
|
||||||
|
return self.__class__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class SlugField(CharField):
|
class SlugField(CharField):
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user