diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 13301f31b4..5def05146c 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -612,6 +612,18 @@ def __init__(self, regex, **kwargs): validator = RegexValidator(regex, message=self.error_messages['invalid']) 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): default_error_messages = { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy