class UUIDField

from django.db.models.fields import UUIDField


  

Ancestors (MRO)

  1. builtins.object
  2. django.db.models.query_utils.RegisterLookupMixin
  3. django.db.models.fields.Field
  4. django.db.models.fields.UUIDField
AttributeValueDefined in
AttributeTypeDefined in
def cached_col(self)
django.db.models.fields.Field
def cast_db_type(self, connection)
django.db.models.fields.Field
Return the data type to use in the Cast() function.
    def cast_db_type(self, connection):
        """Return the data type to use in the Cast() function."""
        db_type = connection.ops.cast_data_types.get(self.get_internal_type())
        if db_type:
            return db_type % self.db_type_parameters(connection)
        return self.db_type(connection)
def check(self, **kwargs)
django.db.models.fields.Field
    def check(self, **kwargs):
        return [
            *self._check_field_name(),
            *self._check_choices(),
            *self._check_db_default(**kwargs),
            *self._check_db_index(),
            *self._check_db_comment(**kwargs),
            *self._check_null_allowed_for_primary_keys(),
            *self._check_backend_specific_checks(**kwargs),
            *self._check_validators(),
            *self._check_deprecation_details(),
        ]
def clean(self, value, model_instance)
django.db.models.fields.Field
Convert the value's type and run validation. Validation errors
from to_python() and validate() are propagated. Return the correct
value if no error is raised.
    def clean(self, value, model_instance):
        """
        Convert the value's type and run validation. Validation errors
        from to_python() and validate() are propagated. Return the correct
        value if no error is raised.
        """
        value = self.to_python(value)
        self.validate(value, model_instance)
        self.run_validators(value)
        return value
def clone(self)
django.db.models.fields.Field
Uses deconstruct() to clone a new copy of this Field.
Will not preserve any class attachments/attribute names.
    def clone(self):
        """
        Uses deconstruct() to clone a new copy of this Field.
        Will not preserve any class attachments/attribute names.
        """
        name, path, args, kwargs = self.deconstruct()
        return self.__class__(*args, **kwargs)
def contribute_to_class(self, cls, name, private_only=False)
django.db.models.fields.Field
Register the field with the model class it belongs to.

If private_only is True, create a separate instance of this field
for every subclass of cls, even if cls is not an abstract model.
    def contribute_to_class(self, cls, name, private_only=False):
        """
        Register the field with the model class it belongs to.

        If private_only is True, create a separate instance of this field
        for every subclass of cls, even if cls is not an abstract model.
        """
        self.set_attributes_from_name(name)
        self.model = cls
        cls._meta.add_field(self, private=private_only)
        if self.column:
            setattr(cls, self.attname, self.descriptor_class(self))
        if self.choices is not None:
            # Don't override a get_FOO_display() method defined explicitly on
            # this class, but don't check methods derived from inheritance, to
            # allow overriding inherited choices. For more complex inheritance
            # structures users should override contribute_to_class().
            if "get_%s_display" % self.name not in cls.__dict__:
                setattr(
                    cls,
                    "get_%s_display" % self.name,
                    partialmethod(cls._get_FIELD_display, field=self),
                )
def db_check(self, connection)
django.db.models.fields.Field
Return the database column check constraint for this field, for the
provided connection. Works the same way as db_type() for the case that
get_internal_type() does not map to a preexisting model field.
    def db_check(self, connection):
        """
        Return the database column check constraint for this field, for the
        provided connection. Works the same way as db_type() for the case that
        get_internal_type() does not map to a preexisting model field.
        """
        data = self.db_type_parameters(connection)
        try:
            return (
                connection.data_type_check_constraints[self.get_internal_type()] % data
            )
        except KeyError:
            return None
def db_parameters(self, connection)
django.db.models.fields.Field
Extension of db_type(), providing a range of different return values
(type, checks). This will look at db_type(), allowing custom model
fields to override it.
    def db_parameters(self, connection):
        """
        Extension of db_type(), providing a range of different return values
        (type, checks). This will look at db_type(), allowing custom model
        fields to override it.
        """
        type_string = self.db_type(connection)
        check_string = self.db_check(connection)
        return {
            "type": type_string,
            "check": check_string,
        }
def db_returning(self)
django.db.models.fields.Field
Private API intended only to be used by Django itself.
def db_tablespace(self)
django.db.models.fields.Field
def db_type(self, connection)
django.db.models.fields.Field
Return the database column data type for this field, for the provided
connection.
    def db_type(self, connection):
        """
        Return the database column data type for this field, for the provided
        connection.
        """
        # The default implementation of this method looks at the
        # backend-specific data_types dictionary, looking up the field by its
        # "internal type".
        #
        # A Field class can implement the get_internal_type() method to specify
        # which *preexisting* Django Field class it's most similar to -- i.e.,
        # a custom field might be represented by a TEXT column type, which is
        # the same as the TextField Django field type, which means the custom
        # field's get_internal_type() returns 'TextField'.
        #
        # But the limitation of the get_internal_type() / data_types approach
        # is that it cannot handle database column types that aren't already
        # mapped to one of the built-in Django field types. In this case, you
        # can implement db_type() instead of get_internal_type() to specify
        # exactly which wacky database column type you want to use.
        data = self.db_type_parameters(connection)
        try:
            column_type = connection.data_types[self.get_internal_type()]
        except KeyError:
            return None
        else:
            # column_type is either a single-parameter function or a string.
            if callable(column_type):
                return column_type(data)
            return column_type % data
def db_type_parameters(self, connection)
django.db.models.fields.Field
    def db_type_parameters(self, connection):
        return DictWrapper(self.__dict__, connection.ops.quote_name, "qn_")
def db_type_suffix(self, connection)
django.db.models.fields.Field
    def db_type_suffix(self, connection):
        return connection.data_types_suffix.get(self.get_internal_type())
def deconstruct(self)
django.db.models.fields.UUIDField
django.db.models.fields.UUIDField
Return enough information to recreate the field as a 4-tuple:

 * The name of the field on the model, if contribute_to_class() has
   been run.
 * The import path of the field, including the class, e.g.
   django.db.models.IntegerField. This should be the most portable
   version, so less specific may be better.
 * A list of positional arguments.
 * A dict of keyword arguments.

Note that the positional or keyword arguments must contain values of
the following types (including inner values of collection types):

 * None, bool, str, int, float, complex, set, frozenset, list, tuple,
   dict
 * UUID
 * datetime.datetime (naive), datetime.date
 * top-level classes, top-level functions - will be referenced by their
   full import path
 * Storage instances - these have their own deconstruct() method

This is because the values here must be serialized into a text format
(possibly new Python code, possibly JSON) and these are the only types
with encoding handlers defined.

There's no need to return the exact way the field was instantiated this
time, just ensure that the resulting field is the same - prefer keyword
arguments over positional ones, and omit parameters with their default
values.
    def deconstruct(self):
        name, path, args, kwargs = super().deconstruct()
        del kwargs["max_length"]
        return name, path, args, kwargs
django.db.models.fields.Field
Return enough information to recreate the field as a 4-tuple:

 * The name of the field on the model, if contribute_to_class() has
   been run.
 * The import path of the field, including the class, e.g.
   django.db.models.IntegerField. This should be the most portable
   version, so less specific may be better.
 * A list of positional arguments.
 * A dict of keyword arguments.

Note that the positional or keyword arguments must contain values of
the following types (including inner values of collection types):

 * None, bool, str, int, float, complex, set, frozenset, list, tuple,
   dict
 * UUID
 * datetime.datetime (naive), datetime.date
 * top-level classes, top-level functions - will be referenced by their
   full import path
 * Storage instances - these have their own deconstruct() method

This is because the values here must be serialized into a text format
(possibly new Python code, possibly JSON) and these are the only types
with encoding handlers defined.

There's no need to return the exact way the field was instantiated this
time, just ensure that the resulting field is the same - prefer keyword
arguments over positional ones, and omit parameters with their default
values.
    def deconstruct(self):
        """
        Return enough information to recreate the field as a 4-tuple:

         * The name of the field on the model, if contribute_to_class() has
           been run.
         * The import path of the field, including the class, e.g.
           django.db.models.IntegerField. This should be the most portable
           version, so less specific may be better.
         * A list of positional arguments.
         * A dict of keyword arguments.

        Note that the positional or keyword arguments must contain values of
        the following types (including inner values of collection types):

         * None, bool, str, int, float, complex, set, frozenset, list, tuple,
           dict
         * UUID
         * datetime.datetime (naive), datetime.date
         * top-level classes, top-level functions - will be referenced by their
           full import path
         * Storage instances - these have their own deconstruct() method

        This is because the values here must be serialized into a text format
        (possibly new Python code, possibly JSON) and these are the only types
        with encoding handlers defined.

        There's no need to return the exact way the field was instantiated this
        time, just ensure that the resulting field is the same - prefer keyword
        arguments over positional ones, and omit parameters with their default
        values.
        """
        # Short-form way of fetching all the default parameters
        keywords = {}
        possibles = {
            "verbose_name": None,
            "primary_key": False,
            "max_length": None,
            "unique": False,
            "blank": False,
            "null": False,
            "db_index": False,
            "default": NOT_PROVIDED,
            "db_default": NOT_PROVIDED,
            "editable": True,
            "serialize": True,
            "unique_for_date": None,
            "unique_for_month": None,
            "unique_for_year": None,
            "choices": None,
            "help_text": "",
            "db_column": None,
            "db_comment": None,
            "db_tablespace": None,
            "auto_created": False,
            "validators": [],
            "error_messages": None,
        }
        attr_overrides = {
            "unique": "_unique",
            "error_messages": "_error_messages",
            "validators": "_validators",
            "verbose_name": "_verbose_name",
            "db_tablespace": "_db_tablespace",
        }
        equals_comparison = {"choices", "validators"}
        for name, default in possibles.items():
            value = getattr(self, attr_overrides.get(name, name))
            if isinstance(value, CallableChoiceIterator):
                value = value.func
            # Do correct kind of comparison
            if name in equals_comparison:
                if value != default:
                    keywords[name] = value
            else:
                if value is not default:
                    keywords[name] = value
        # Work out path - we shorten it for known Django core fields
        path = "%s.%s" % (self.__class__.__module__, self.__class__.__qualname__)
        if path.startswith("django.db.models.fields.related"):
            path = path.replace("django.db.models.fields.related", "django.db.models")
        elif path.startswith("django.db.models.fields.files"):
            path = path.replace("django.db.models.fields.files", "django.db.models")
        elif path.startswith("django.db.models.fields.generated"):
            path = path.replace("django.db.models.fields.generated", "django.db.models")
        elif path.startswith("django.db.models.fields.json"):
            path = path.replace("django.db.models.fields.json", "django.db.models")
        elif path.startswith("django.db.models.fields.proxy"):
            path = path.replace("django.db.models.fields.proxy", "django.db.models")
        elif path.startswith("django.db.models.fields"):
            path = path.replace("django.db.models.fields", "django.db.models")
        # Return basic info - other fields should override this.
        return (self.name, path, [], keywords)
def description(self)
django.db.models.fields.Field
def error_messages(self)
django.db.models.fields.Field
def flatchoices(self)
django.db.models.fields.Field
Flattened version of choices tuple.
def formfield(self, **kwargs)
django.db.models.fields.UUIDField
django.db.models.fields.UUIDField
Return a django.forms.Field instance for this field.
    def formfield(self, **kwargs):
        return super().formfield(
            **{
                "form_class": forms.UUIDField,
                **kwargs,
            }
        )
django.db.models.fields.Field
Return a django.forms.Field instance for this field.
    def formfield(self, form_class=None, choices_form_class=None, **kwargs):
        """Return a django.forms.Field instance for this field."""
        defaults = {
            "required": not self.blank,
            "label": capfirst(self.verbose_name),
            "help_text": self.help_text,
        }
        if self.has_default():
            if callable(self.default):
                defaults["initial"] = self.default
                defaults["show_hidden_initial"] = True
            else:
                defaults["initial"] = self.get_default()
        if self.choices is not None:
            # Fields with choices get special treatment.
            include_blank = self.blank or not (
                self.has_default() or "initial" in kwargs
            )
            defaults["choices"] = self.get_choices(include_blank=include_blank)
            defaults["coerce"] = self.to_python
            if self.null:
                defaults["empty_value"] = None
            if choices_form_class is not None:
                form_class = choices_form_class
            else:
                form_class = forms.TypedChoiceField
            # Many of the subclass-specific formfield arguments (min_value,
            # max_value) don't apply for choice fields, so be sure to only pass
            # the values that TypedChoiceField will understand.
            for k in list(kwargs):
                if k not in (
                    "coerce",
                    "empty_value",
                    "choices",
                    "required",
                    "widget",
                    "label",
                    "initial",
                    "help_text",
                    "error_messages",
                    "show_hidden_initial",
                    "disabled",
                ):
                    del kwargs[k]
        defaults.update(kwargs)
        if form_class is None:
            form_class = forms.CharField
        return form_class(**defaults)
def get_attname(self)
django.db.models.fields.Field
    def get_attname(self):
        return self.name
def get_attname_column(self)
django.db.models.fields.Field
    def get_attname_column(self):
        attname = self.get_attname()
        column = self.db_column or attname
        return attname, column
def get_choices(self, include_blank=True, blank_choice=[('', '---------')], limit_choices_to=None, ordering=())
django.db.models.fields.Field
Return choices with a default blank choices included, for use
as <select> choices for this field.
    def get_choices(
        self,
        include_blank=True,
        blank_choice=BLANK_CHOICE_DASH,
        limit_choices_to=None,
        ordering=(),
    ):
        """
        Return choices with a default blank choices included, for use
        as <select> choices for this field.
        """
        if self.choices is not None:
            if include_blank:
                return BlankChoiceIterator(self.choices, blank_choice)
            return self.choices
        rel_model = self.remote_field.model
        limit_choices_to = limit_choices_to or self.get_limit_choices_to()
        choice_func = operator.attrgetter(
            self.remote_field.get_related_field().attname
            if hasattr(self.remote_field, "get_related_field")
            else "pk"
        )
        qs = rel_model._default_manager.complex_filter(limit_choices_to)
        if ordering:
            qs = qs.order_by(*ordering)
        return (blank_choice if include_blank else []) + [
            (choice_func(x), str(x)) for x in qs
        ]
def get_class_lookups(self)
django.db.models.query_utils.RegisterLookupMixin
    @functools.cache
    def get_class_lookups(cls):
        class_lookups = [
            parent.__dict__.get("class_lookups", {}) for parent in inspect.getmro(cls)
        ]
        return cls.merge_dicts(class_lookups)
def get_col(self, alias, output_field=None)
django.db.models.fields.Field
    def get_col(self, alias, output_field=None):
        if alias == self.model._meta.db_table and (
            output_field is None or output_field == self
        ):
            return self.cached_col
        from django.db.models.expressions import Col

        return Col(alias, self, output_field)
def get_db_converters(self, connection)
django.db.models.fields.Field
    def get_db_converters(self, connection):
        if hasattr(self, "from_db_value"):
            return [self.from_db_value]
        return []
def get_db_prep_save(self, value, connection)
django.db.models.fields.Field
Return field's value prepared for saving into a database.
    def get_db_prep_save(self, value, connection):
        """Return field's value prepared for saving into a database."""
        if hasattr(value, "as_sql"):
            return value
        return self.get_db_prep_value(value, connection=connection, prepared=False)
def get_db_prep_value(self, value, connection, prepared=False)
django.db.models.fields.UUIDField
django.db.models.fields.UUIDField
Return field's value prepared for interacting with the database backend.

Used by the default implementations of get_db_prep_save().
    def get_db_prep_value(self, value, connection, prepared=False):
        if value is None:
            return None
        if not isinstance(value, uuid.UUID):
            value = self.to_python(value)

        if connection.features.has_native_uuid_field:
            return value
        return value.hex
django.db.models.fields.Field
Return field's value prepared for interacting with the database backend.

Used by the default implementations of get_db_prep_save().
    def get_db_prep_value(self, value, connection, prepared=False):
        """
        Return field's value prepared for interacting with the database backend.

        Used by the default implementations of get_db_prep_save().
        """
        if not prepared:
            value = self.get_prep_value(value)
        return value
def get_default(self)
django.db.models.fields.Field
Return the default value for this field.
    def get_default(self):
        """Return the default value for this field."""
        return self._get_default()
def get_filter_kwargs_for_object(self, obj)
django.db.models.fields.Field
Return a dict that when passed as kwargs to self.model.filter(), would
yield all instances having the same value for this field as obj has.
    def get_filter_kwargs_for_object(self, obj):
        """
        Return a dict that when passed as kwargs to self.model.filter(), would
        yield all instances having the same value for this field as obj has.
        """
        return {self.name: getattr(obj, self.attname)}
def get_instance_lookups(self)
django.db.models.query_utils.RegisterLookupMixin
    def get_instance_lookups(self):
        class_lookups = self.get_class_lookups()
        if instance_lookups := getattr(self, "instance_lookups", None):
            return {**class_lookups, **instance_lookups}
        return class_lookups
def get_internal_type(self)
django.db.models.fields.UUIDField
django.db.models.fields.UUIDField
    def get_internal_type(self):
        return "UUIDField"
django.db.models.fields.Field
    def get_internal_type(self):
        return self.__class__.__name__
def get_lookup(self, lookup_name)
django.db.models.query_utils.RegisterLookupMixin
    def get_lookup(self, lookup_name):
        from django.db.models.lookups import Lookup

        found = self._get_lookup(lookup_name)
        if found is None and hasattr(self, "output_field"):
            return self.output_field.get_lookup(lookup_name)
        if found is not None and not issubclass(found, Lookup):
            return None
        return found
def get_pk_value_on_save(self, instance)
django.db.models.fields.Field
Hook to generate new PK values on save. This method is called when
saving instances with no primary key value set. If this method returns
something else than None, then the returned value is used when saving
the new instance.
    def get_pk_value_on_save(self, instance):
        """
        Hook to generate new PK values on save. This method is called when
        saving instances with no primary key value set. If this method returns
        something else than None, then the returned value is used when saving
        the new instance.
        """
        if self.default:
            return self.get_default()
        return None
def get_prep_value(self, value)
django.db.models.fields.UUIDField
django.db.models.fields.UUIDField
Perform preliminary non-db specific value checks and conversions.
    def get_prep_value(self, value):
        value = super().get_prep_value(value)
        return self.to_python(value)
django.db.models.fields.Field
Perform preliminary non-db specific value checks and conversions.
    def get_prep_value(self, value):
        """Perform preliminary non-db specific value checks and conversions."""
        if isinstance(value, Promise):
            value = value._proxy____cast()
        return value
def get_transform(self, lookup_name)
django.db.models.query_utils.RegisterLookupMixin
    def get_transform(self, lookup_name):
        from django.db.models.lookups import Transform

        found = self._get_lookup(lookup_name)
        if found is None and hasattr(self, "output_field"):
            return self.output_field.get_transform(lookup_name)
        if found is not None and not issubclass(found, Transform):
            return None
        return found
def has_default(self)
django.db.models.fields.Field
Return a boolean of whether this field has a default value.
    def has_default(self):
        """Return a boolean of whether this field has a default value."""
        return self.default is not NOT_PROVIDED
def merge_dicts(dicts)
django.db.models.query_utils.RegisterLookupMixin
Merge dicts in reverse to preference the order of the original list. e.g.,
merge_dicts([a, b]) will preference the keys in 'a' over those in 'b'.
    @staticmethod
    def merge_dicts(dicts):
        """
        Merge dicts in reverse to preference the order of the original list. e.g.,
        merge_dicts([a, b]) will preference the keys in 'a' over those in 'b'.
        """
        merged = {}
        for d in reversed(dicts):
            merged.update(d)
        return merged
def pre_save(self, model_instance, add)
django.db.models.fields.Field
Return field's value just before saving.
    def pre_save(self, model_instance, add):
        """Return field's value just before saving."""
        value = getattr(model_instance, self.attname)
        if not connection.features.supports_default_keyword_in_insert:
            from django.db.models.expressions import DatabaseDefault

            if isinstance(value, DatabaseDefault):
                return self._db_default_expression
        return value
def register_class_lookup(cls, lookup, lookup_name=None)
django.db.models.query_utils.RegisterLookupMixin
    def register_class_lookup(cls, lookup, lookup_name=None):
        if lookup_name is None:
            lookup_name = lookup.lookup_name
        if "class_lookups" not in cls.__dict__:
            cls.class_lookups = {}
        cls.class_lookups[lookup_name] = lookup
        cls._clear_cached_class_lookups()
        return lookup
def register_instance_lookup(self, lookup, lookup_name=None)
django.db.models.query_utils.RegisterLookupMixin
    def register_instance_lookup(self, lookup, lookup_name=None):
        if lookup_name is None:
            lookup_name = lookup.lookup_name
        if "instance_lookups" not in self.__dict__:
            self.instance_lookups = {}
        self.instance_lookups[lookup_name] = lookup
        return lookup
def rel_db_type(self, connection)
django.db.models.fields.Field
Return the data type that a related field pointing to this field should
use. For example, this method is called by ForeignKey and OneToOneField
to determine its data type.
    def rel_db_type(self, connection):
        """
        Return the data type that a related field pointing to this field should
        use. For example, this method is called by ForeignKey and OneToOneField
        to determine its data type.
        """
        return self.db_type(connection)
def run_validators(self, value)
django.db.models.fields.Field
    def run_validators(self, value):
        if value in self.empty_values:
            return

        errors = []
        for v in self.validators:
            try:
                v(value)
            except exceptions.ValidationError as e:
                if hasattr(e, "code") and e.code in self.error_messages:
                    e.message = self.error_messages[e.code]
                errors.extend(e.error_list)

        if errors:
            raise exceptions.ValidationError(errors)
def save_form_data(self, instance, data)
django.db.models.fields.Field
    def save_form_data(self, instance, data):
        setattr(instance, self.name, data)
def select_format(self, compiler, sql, params)
django.db.models.fields.Field
Custom format for select clauses. For example, GIS columns need to be
selected as AsText(table.col) on MySQL as the table.col data can't be
used by Django.
    def select_format(self, compiler, sql, params):
        """
        Custom format for select clauses. For example, GIS columns need to be
        selected as AsText(table.col) on MySQL as the table.col data can't be
        used by Django.
        """
        return sql, params
def set_attributes_from_name(self, name)
django.db.models.fields.Field
    def set_attributes_from_name(self, name):
        self.name = self.name or name
        self.attname, self.column = self.get_attname_column()
        self.concrete = self.column is not None
        if self.verbose_name is None and self.name:
            self.verbose_name = self.name.replace("_", " ")
def to_python(self, value)
django.db.models.fields.UUIDField
django.db.models.fields.UUIDField
Convert the input value into the expected Python data type, raising
django.core.exceptions.ValidationError if the data can't be converted.
Return the converted value. Subclasses should override this.
    def to_python(self, value):
        if value is not None and not isinstance(value, uuid.UUID):
            input_form = "int" if isinstance(value, int) else "hex"
            try:
                return uuid.UUID(**{input_form: value})
            except (AttributeError, ValueError):
                raise exceptions.ValidationError(
                    self.error_messages["invalid"],
                    code="invalid",
                    params={"value": value},
                )
        return value
django.db.models.fields.Field
Convert the input value into the expected Python data type, raising
django.core.exceptions.ValidationError if the data can't be converted.
Return the converted value. Subclasses should override this.
    def to_python(self, value):
        """
        Convert the input value into the expected Python data type, raising
        django.core.exceptions.ValidationError if the data can't be converted.
        Return the converted value. Subclasses should override this.
        """
        return value
def unique(self)
django.db.models.fields.Field
def validate(self, value, model_instance)
django.db.models.fields.Field
Validate value and raise ValidationError if necessary. Subclasses
should override this to provide validation logic.
    def validate(self, value, model_instance):
        """
        Validate value and raise ValidationError if necessary. Subclasses
        should override this to provide validation logic.
        """
        if not self.editable:
            # Skip validation for non-editable fields.
            return

        if self.choices is not None and value not in self.empty_values:
            for option_key, option_value in self.choices:
                if isinstance(option_value, (list, tuple)):
                    # This is an optgroup, so look inside the group for
                    # options.
                    for optgroup_key, optgroup_value in option_value:
                        if value == optgroup_key:
                            return
                elif value == option_key:
                    return
            raise exceptions.ValidationError(
                self.error_messages["invalid_choice"],
                code="invalid_choice",
                params={"value": value},
            )

        if value is None and not self.null:
            raise exceptions.ValidationError(self.error_messages["null"], code="null")

        if not self.blank and value in self.empty_values:
            raise exceptions.ValidationError(self.error_messages["blank"], code="blank")
def validators(self)
django.db.models.fields.Field
Some validators can't be created at field initialization time.
This method provides a way to delay their creation until required.
def value_from_object(self, obj)
django.db.models.fields.Field
Return the value of this field in the given model instance.
    def value_from_object(self, obj):
        """Return the value of this field in the given model instance."""
        return getattr(obj, self.attname)
def value_to_string(self, obj)
django.db.models.fields.Field
Return a string value of this field from the passed obj.
This is used by the serialization framework.
    def value_to_string(self, obj):
        """
        Return a string value of this field from the passed obj.
        This is used by the serialization framework.
        """
        return str(self.value_from_object(obj))