diff options
Diffstat (limited to 'rest_framework/fields.py')
| -rw-r--r-- | rest_framework/fields.py | 20 | 
1 files changed, 10 insertions, 10 deletions
| diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 4f06d186..9d96cf5c 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -137,6 +137,16 @@ class Field(object):          messages.update(error_messages or {})          self.error_messages = messages +    def __new__(cls, *args, **kwargs): +        """ +        When a field is instantiated, we store the arguments that were used, +        so that we can present a helpful representation of the object. +        """ +        instance = super(Field, cls).__new__(cls) +        instance._args = args +        instance._kwargs = kwargs +        return instance +      def bind(self, field_name, parent, root):          """          Setup the context for the field instance. @@ -249,16 +259,6 @@ class Field(object):              raise AssertionError(msg)          raise ValidationError(msg.format(**kwargs)) -    def __new__(cls, *args, **kwargs): -        """ -        When a field is instantiated, we store the arguments that were used, -        so that we can present a helpful representation of the object. -        """ -        instance = super(Field, cls).__new__(cls) -        instance._args = args -        instance._kwargs = kwargs -        return instance -      def __repr__(self):          return representation.field_repr(self) | 
