Django LowerCaseCharField

后端 未结 4 961
我在风中等你
我在风中等你 2021-02-13 17:22

We implemented a LowerCaseCharField. We would be happy to hear better implementation suggestions.

from django.db.models.fields import CharField

class LowerCaseC         


        
4条回答
  •  感动是毒
    2021-02-13 17:58

    Using Python properties is not straightforward because of the way django.models.Models magically set their instance attributes based on class attributes. There is an open bug out for this.

    I ended up doing exactly what the original poster did.

    It means you have to do:

    >>> modelinstance.field_name="TEST"
    >>> modelinstance.save() # Extra step
    >>> print modelinstance.field_name
    'test'
    

提交回复
热议问题