Python django.db.models 模块,IPAddressField() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用django.db.models.IPAddressField()

项目:Kiwi    作者:kiwitcms    | 项目源码 | 文件源码
def clean(self):
        strip_types = (models.CharField,
                       models.TextField,
                       models.URLField,
                       models.EmailField,
                       models.IPAddressField,
                       models.GenericIPAddressField,
                       models.SlugField)

        for field in self._meta.fields:
            # TODO: hardcode 'notes' here
            if not (field.name is 'notes') and isinstance(field, strip_types):
                value = getattr(self, field.name)
                if value:
                    setattr(self, field.name,
                            value.replace('\t', ' ').replace('\n', ' ').replace('\r', ' '))