当前位置: 首页>>代码示例>>Python>>正文


Python CharField.contribute_to_class方法代码示例

本文整理汇总了Python中django.db.models.CharField.contribute_to_class方法的典型用法代码示例。如果您正苦于以下问题:Python CharField.contribute_to_class方法的具体用法?Python CharField.contribute_to_class怎么用?Python CharField.contribute_to_class使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.db.models.CharField的用法示例。


在下文中一共展示了CharField.contribute_to_class方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: contribute_to_class

# 需要导入模块: from django.db.models import CharField [as 别名]
# 或者: from django.db.models.CharField import contribute_to_class [as 别名]
    def contribute_to_class(self, model, name):
        super(MongoUserManager, self).contribute_to_class(model, name)
        self.dj_model = self.model
        self.model = get_user_document()

        self.dj_model.USERNAME_FIELD = self.model.USERNAME_FIELD
        username = CharField(_('username'), max_length=30, unique=True)
        username.contribute_to_class(self.dj_model, self.dj_model.USERNAME_FIELD)

        self.dj_model.REQUIRED_FIELDS = self.model.REQUIRED_FIELDS
        for name in self.dj_model.REQUIRED_FIELDS:
            field = CharField(_(name), max_length=30)
            field.contribute_to_class(self.dj_model, name)

        is_staff = BooleanField(_('is_staff'), default=False)
        is_staff.contribute_to_class(self.dj_model, 'is_staff')

        is_active = BooleanField(_('is_active'), default=False)
        is_active.contribute_to_class(self.dj_model, 'is_active')

        is_superuser = BooleanField(_('is_superuser'), default=False)
        is_superuser.contribute_to_class(self.dj_model, 'is_superuser')

        last_login = DateTimeField(_('last_login'), auto_now_add=True)
        last_login.contribute_to_class(self.dj_model, 'last_login')

        date_joined = DateTimeField(_('date_joined'), auto_now_add=True)
        date_joined.contribute_to_class(self.dj_model, 'date_joined')
开发者ID:MongoEngine,项目名称:django-mongoengine,代码行数:30,代码来源:managers.py

示例2: contribute_to_class

# 需要导入模块: from django.db.models import CharField [as 别名]
# 或者: from django.db.models.CharField import contribute_to_class [as 别名]
 def contribute_to_class(self, cls, name):
     self.name = name
     self.fk_field_name = name + '_fk'
     self.ft_field_name = name + '_ft'
     setattr(cls, name, self)
     fk_field = ForeignKey(self.foreign_model, blank=True, null=True)
     fk_field.contribute_to_class(cls, self.fk_field_name)
     ft_field = CharField(max_length=255, blank=True)
     ft_field.contribute_to_class(cls, self.ft_field_name)
开发者ID:ClinicalSoftwareSolutions,项目名称:opal,代码行数:11,代码来源:fields.py

示例3: contribute_to_class

# 需要导入模块: from django.db.models import CharField [as 别名]
# 或者: from django.db.models.CharField import contribute_to_class [as 别名]
 def contribute_to_class(self, cls, name):
     self.name = name
     self.fk_field_name = name + '_fk'
     self.ft_field_name = name + '_ft'
     setattr(cls, name, self)
     fk_kwargs = dict(blank=True, null=True)
     if self.related_name:
         fk_kwargs['related_name'] = self.related_name
     fk_field = ForeignKey(self.foreign_model, **fk_kwargs)
     fk_field.contribute_to_class(cls, self.fk_field_name)
     ft_field = CharField(max_length=255, blank=True, null=True, default='')
     ft_field.contribute_to_class(cls, self.ft_field_name)
开发者ID:anukat2015,项目名称:opal-1,代码行数:14,代码来源:fields.py

示例4: contribute_to_class

# 需要导入模块: from django.db.models import CharField [as 别名]
# 或者: from django.db.models.CharField import contribute_to_class [as 别名]
    def contribute_to_class(self, model, name):
        super(MongoUserManager, self).contribute_to_class(model, name)
        self.dj_model = self.model
        self.model = get_user_document()

        self.dj_model.USERNAME_FIELD = self.model.USERNAME_FIELD
        username = CharField(_('username'), max_length=30, unique=True)
        username.contribute_to_class(self.dj_model, self.dj_model.USERNAME_FIELD)

        self.dj_model.REQUIRED_FIELDS = self.model.REQUIRED_FIELDS
        for name in self.dj_model.REQUIRED_FIELDS:
            field = CharField(_(name), max_length=30)
            field.contribute_to_class(self.dj_model, name)
开发者ID:noscripter,项目名称:django-mongoengine,代码行数:15,代码来源:__init__.py


注:本文中的django.db.models.CharField.contribute_to_class方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。