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


Python models.CharField类代码示例

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


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

示例1: ready

 def ready(self):
     # Connections may already exist before we are called.
     for conn in connections.all():
         if conn.connection is not None:
             register_type_handlers(conn)
     connection_created.connect(register_type_handlers)
     CharField.register_lookup(Unaccent)
     TextField.register_lookup(Unaccent)
     CharField.register_lookup(SearchLookup)
     TextField.register_lookup(SearchLookup)
     CharField.register_lookup(TrigramSimilar)
     TextField.register_lookup(TrigramSimilar)
开发者ID:KIKUYA-Takumi,项目名称:django,代码行数:12,代码来源:apps.py

示例2: __init__

 def __init__(self, *args, **kwargs):
     kwargs.setdefault('editable', True)
     kwargs.setdefault('verbose_name', _('Initials'))
     kwargs.setdefault('max_length', 3)
     kwargs.setdefault(
         'help_text', _('Type 2-3 letters, all in uppercase and no spaces'))
     CharField.__init__(self, *args, **kwargs)
开发者ID:botswana-harvard,项目名称:edc-base,代码行数:7,代码来源:custom_fields.py

示例3: __init__

    def __init__(self, based_fields=None, zoom=None, suffix='', 
                 max_length=63, *args, **kwargs):

        super(PlainLocationField, self).__init__(based_fields=based_fields,
                                                 zoom=zoom, suffix=suffix, *args, **kwargs)

        CharField.__init__(self, max_length=max_length, *args, **kwargs)
开发者ID:Ellipsis753,项目名称:django-location-field-plain,代码行数:7,代码来源:models.py

示例4: __init__

 def __init__(self, *args, **kwargs):
     kwargs.setdefault('editable', False)
     kwargs.setdefault('blank', True)
     kwargs.setdefault('max_length', 50)
     kwargs.setdefault('verbose_name', 'Hostname')
     kwargs.setdefault('default', socket.gethostname())
     CharField.__init__(self, *args, **kwargs)
开发者ID:botswana-harvard,项目名称:edc,代码行数:7,代码来源:hostname_modification_field.py

示例5: __init__

 def __init__(self, *args, **kwargs):
     kwargs.setdefault('verbose_name', _('What type of identity number is this?'))
     kwargs.setdefault('editable', True)
     kwargs.setdefault('max_length', 15)
     kwargs.setdefault('choices', IDENTITY_TYPE)
     # kwargs.setdefault('help_text', _('Format is 9999[12]9999'))
     CharField.__init__(self, *args, **kwargs)
开发者ID:botswana-harvard,项目名称:edc,代码行数:7,代码来源:custom_fields.py

示例6: __init__

 def __init__(self, *args, **kwargs):
     kwargs.setdefault('editable', False)
     kwargs.setdefault('blank', True)
     kwargs.setdefault('null', True)
     kwargs.setdefault('max_length', 150)
     kwargs.setdefault('verbose_name', 'Revision')
     CharField.__init__(self, *args, **kwargs)
开发者ID:botswana-harvard,项目名称:edc,代码行数:7,代码来源:revision_field.py

示例7: __init__

    def __init__(self, max_length=63, *args, **kwargs):
        super(PlainLocationField, self).__init__(*args, **kwargs)

        kwargs.pop('based_fields', None)
        kwargs.pop('zoom', None)
        kwargs.pop('suffix', None)

        CharField.__init__(self, max_length=max_length, *args, **kwargs)
开发者ID:NOUSguide,项目名称:django-location-field,代码行数:8,代码来源:plain.py

示例8: __init__

 def __init__(self, *args, **kwargs):
     kwargs['max_length'] = kwargs.get('max_length', 32 )
     try:
         self.auto = kwargs['auto']
         del kwargs['auto']
     except KeyError:
         self.auto = True
     CharField.__init__(self, *args, **kwargs)
开发者ID:campherkurt,项目名称:django-sms-payments,代码行数:8,代码来源:fields.py

示例9: contribute_to_class

 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,代码行数:9,代码来源:fields.py

示例10: __init__

	def __init__(self, verbose_name=None, name=None, auto=True, version=1, node=None, clock_seq=None, namespace=None, **kwargs):
		kwargs['max_length'] = 36
		if auto:
			kwargs['blank'] = True
			kwargs.setdefault('editable', False)
		self.version = version
		if version==1:
			self.node, self.clock_seq = node, clock_seq
		elif version==3 or version==5:
			self.namespace, self.name = namespace, name
		CharField.__init__(self, verbose_name, name, **kwargs)
开发者ID:myles-archive,项目名称:asgard-utils,代码行数:11,代码来源:fields.py

示例11: test_transform

 def test_transform(self):
     query = Query(Author)
     CharField.register_lookup(Lower, 'lower')
     try:
         where = query.build_where(~Q(name__lower='foo'))
     finally:
         CharField._unregister_lookup(Lower, 'lower')
     lookup = where.children[0]
     self.assertIsInstance(lookup, Exact)
     self.assertIsInstance(lookup.lhs, Lower)
     self.assertIsInstance(lookup.lhs.lhs, SimpleCol)
     self.assertEqual(lookup.lhs.lhs.target, Author._meta.get_field('name'))
开发者ID:NewbiePanda,项目名称:django,代码行数:12,代码来源:test_query.py

示例12: test_transform

 def test_transform(self):
     new_name = self.t1.name.upper()
     self.assertNotEqual(self.t1.name, new_name)
     Tag.objects.create(name=new_name)
     CharField.register_lookup(Lower)
     try:
         self.assertCountEqual(
             Tag.objects.order_by().distinct('name__lower'),
             [self.t1, self.t2, self.t3, self.t4, self.t5],
         )
     finally:
         CharField._unregister_lookup(Lower)
开发者ID:CodeMonk,项目名称:django,代码行数:12,代码来源:tests.py

示例13: contribute_to_class

 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,代码行数:12,代码来源:fields.py

示例14: test_length_transform

 def test_length_transform(self):
     try:
         CharField.register_lookup(Length, 'length')
         Author.objects.create(name='John Smith', alias='smithj')
         Author.objects.create(name='Rhonda')
         authors = Author.objects.filter(name__length__gt=7)
         self.assertQuerysetEqual(
             authors.order_by('name'), [
                 'John Smith',
             ],
             lambda a: a.name
         )
     finally:
         CharField._unregister_lookup(Length, 'length')
开发者ID:CrazyChief,项目名称:django,代码行数:14,代码来源:tests.py

示例15: test_upper_transform

 def test_upper_transform(self):
     try:
         CharField.register_lookup(Upper, 'upper')
         Author.objects.create(name='John Smith', alias='smithj')
         Author.objects.create(name='Rhonda')
         authors = Author.objects.filter(name__upper__exact='JOHN SMITH')
         self.assertQuerysetEqual(
             authors.order_by('name'), [
                 'John Smith',
             ],
             lambda a: a.name
         )
     finally:
         CharField._unregister_lookup(Upper, 'upper')
开发者ID:CrazyChief,项目名称:django,代码行数:14,代码来源:tests.py


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