Ticket #5931: db_models_fields_repr.diff

File db_models_fields_repr.diff, 1.1 KB (added by Thomas Güttler <hv@…>, 17 years ago)
  • tests/regressiontests/model_fields/tests.py

     
    1515Traceback (most recent call last):
    1616...
    1717ValidationError: [u'This value must be a decimal number.']
     18
     19>>> repr(f)
     20'<django.db.models.fields.DecimalField None>'
    1821"""
  • django/db/models/fields/__init__.py

     
    402402        "Returns the value of this field in the given model instance."
    403403        return getattr(obj, self.attname)
    404404
     405    def __repr__(self):
     406        "Display the name of the field, too. Usefull for debugging."
     407        return '<%s.%s %s>' % (self.__class__.__module__, self.__class__.__name__, getattr(self, "name", None))
     408   
    405409class AutoField(Field):
    406410    empty_strings_allowed = False
    407411    def __init__(self, *args, **kwargs):
Back to Top