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


Python ForeignKey.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from django.db.models.fields.related import ForeignKey [as 别名]
# 或者: from django.db.models.fields.related.ForeignKey import __init__ [as 别名]
 def __init__(self, to, chained_field=None, chained_model_field=None, show_all=False, auto_choose=False, **kwargs):
     if isinstance(to, basestring):
         self.app_name, self.model_name = to.split('.')
     else:
         self.app_name = to._meta.app_label
         self.model_name = to._meta.object_name
     self.chain_field = chained_field
     self.model_field = chained_model_field
     self.show_all = show_all
     self.auto_choose = auto_choose
     ForeignKey.__init__(self, to, **kwargs)
开发者ID:Anber,项目名称:django-smart-selects,代码行数:13,代码来源:db_fields.py

示例2: __init__

# 需要导入模块: from django.db.models.fields.related import ForeignKey [as 别名]
# 或者: from django.db.models.fields.related.ForeignKey import __init__ [as 别名]
    def __init__(self, to, address_field=None, **kwargs):

        if isinstance(to, six.string_types):
            self.app_name, self.model_name = to.split('.')
        else:
            self.app_name = to._meta.app_label
            self.model_name = to._meta.object_name

        self.address_field = address_field
        kwargs.setdefault('blank', True)
        kwargs.setdefault('null', True)

        ForeignKey.__init__(self, to, **kwargs)
开发者ID:SergeyTsaplin,项目名称:django-fias,代码行数:15,代码来源:address.py

示例3: __init__

# 需要导入模块: from django.db.models.fields.related import ForeignKey [as 别名]
# 或者: from django.db.models.fields.related.ForeignKey import __init__ [as 别名]
 def __init__(self, to, chained_field=None, chained_model_field=None,
              show_all=False, auto_choose=False, view_name=None, exclude_self=None, **kwargs):
     if isinstance(to, basestring):
         self.app_name, self.model_name = to.split('.')
     else:
         self.app_name = to._meta.app_label
         self.model_name = to._meta.object_name
     self.chain_field = chained_field
     self.model_field = chained_model_field
     self.show_all = show_all
     self.auto_choose = auto_choose
     self.view_name = view_name
     ForeignKey.__init__(self, to, **kwargs)
     self.exclude_self = exclude_self
     #TODO: clean-up
     if exclude_self:
         self.exclude_self = exclude_self
开发者ID:zhangguiyu,项目名称:django-smart-selects,代码行数:19,代码来源:db_fields.py

示例4: __init__

# 需要导入模块: from django.db.models.fields.related import ForeignKey [as 别名]
# 或者: from django.db.models.fields.related.ForeignKey import __init__ [as 别名]
    def __init__(self, to, chained_field=None, chained_model_field=None,
                 show_all=False, auto_choose=False, view_name=None, **kwargs):
        """
        examples:

        class Continent(models.Model):
            name = models.CharField(max_length=255)

        class Country(models.Model):
            continent = models.ForeignKey(Continent)

        class Location(models.Model):
            continent = models.ForeignKey(Continent)
            country = ChainedForeignKey(
                Country,
                chained_field="continent",
                chained_model_field="continent",
                show_all=True,
                auto_choose=True,
                # limit_choices_to={'name':'test'}
            )
        ``chained_field`` is the name of the ForeignKey field referenced by ChainedForeignKey of the same Model.
        in the examples, chained_field is the name of field continent in Model Location.

        ``chained_model_field`` is the name of the ForeignKey field referenced in the 'to' Model.
        in the examples, chained_model_field is the name of field continent in Model Country.

        ``show_all`` controls whether show other choices below the filtered choices, with separater '----------'.

        ``auto_choose`` controls whether auto select the choice when there is only one available choice.

        ``view_name`` controls which view to use, 'chained_filter' or 'chained_filter_all'.

        """
        if isinstance(to, six.string_types):
            self.to_app_name, self.to_model_name = to.split('.')
        else:
            self.to_app_name = to._meta.app_label
            self.to_model_name = to._meta.object_name
        self.chained_field = chained_field
        self.chained_model_field = chained_model_field
        self.show_all = show_all
        self.auto_choose = auto_choose
        self.view_name = view_name
        ForeignKey.__init__(self, to, **kwargs)
开发者ID:DjangoBD,项目名称:django-smart-selects,代码行数:47,代码来源:db_fields.py

示例5: __init__

# 需要导入模块: from django.db.models.fields.related import ForeignKey [as 别名]
# 或者: from django.db.models.fields.related.ForeignKey import __init__ [as 别名]
 def __init__(self, to, group_field, **kwargs):
     self.group_field = group_field
     self._choices = True
     ForeignKey.__init__(self, to, **kwargs)
开发者ID:SmartgreenSA,项目名称:django-smart-selects,代码行数:6,代码来源:db_fields.py

示例6: __init__

# 需要导入模块: from django.db.models.fields.related import ForeignKey [as 别名]
# 或者: from django.db.models.fields.related.ForeignKey import __init__ [as 别名]
 def __init__(self, to='fias.AddrObj', **kwargs):
     kwargs.setdefault('related_name', '+')
     ForeignKey.__init__(self, to, **kwargs)
开发者ID:Apocalepse,项目名称:django-fias,代码行数:5,代码来源:address.py

示例7: __init__

# 需要导入模块: from django.db.models.fields.related import ForeignKey [as 别名]
# 或者: from django.db.models.fields.related.ForeignKey import __init__ [as 别名]
 def __init__(self, translated_field, language, to, to_field=None, *args,
              **kwargs):
     self._related_pre_init(translated_field, language, *args, **kwargs)
     ForeignKey.__init__(self, to, to_field, **kwargs)
     self._related_post_init()
开发者ID:kellycreativetech,项目名称:django-modeltranslation,代码行数:7,代码来源:fields.py

示例8: __init__

# 需要导入模块: from django.db.models.fields.related import ForeignKey [as 别名]
# 或者: from django.db.models.fields.related.ForeignKey import __init__ [as 别名]
 def __init__(self, to, chained_field, chained_model_field, *args, **kwargs):
     self.app_name = to._meta.app_label
     self.model_name = to._meta.object_name
     self.chain_field = chained_field
     self.model_field = chained_model_field
     ForeignKey.__init__(self, to, *args, **kwargs)
开发者ID:Entropius,项目名称:recordbook,代码行数:8,代码来源:db_fields.py

示例9: __init__

# 需要导入模块: from django.db.models.fields.related import ForeignKey [as 别名]
# 或者: from django.db.models.fields.related.ForeignKey import __init__ [as 别名]
 def __init__(self, to, to_field=None, rel_class=ManyToOneRel, **kwargs):
     ForeignKey.__init__(self, to, to_field=to_field, rel_class=rel_class, **kwargs)
     self.on_delete = DO_NOTHING
开发者ID:Betriebsrat,项目名称:ecm,代码行数:5,代码来源:softfk.py


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