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


Python ManyToManyField.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from django.db.models.fields.related import ManyToManyField [as 别名]
# 或者: from django.db.models.fields.related.ManyToManyField import __init__ [as 别名]
 def __init__(self, to, chained_field=None, chained_model_field=None,
              show_all=False, auto_choose=False, view_name=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
     ManyToManyField.__init__(self, to, **kwargs)
开发者ID:rashivkp,项目名称:django-smart-selects,代码行数:15,代码来源:db_fields.py

示例2: __init__

# 需要导入模块: from django.db.models.fields.related import ManyToManyField [as 别名]
# 或者: from django.db.models.fields.related.ManyToManyField import __init__ [as 别名]
 def __init__(self, to, **kwargs):
     ManyToManyFieldOriginal.__init__(to, **kwargs)
     self.model = None
     self.query_field_name = ''
     self.core_filters = {}
     self.instance = None
     self.symmetrical = None
     self.source_field = None
     self.source_field_name = ''
     self.target_field_name = ''
     self.reverse = None
     self.through = None
     self.prefetch_cache_name = None
     self.related_val = None
开发者ID:TestingCI,项目名称:pylint-django,代码行数:16,代码来源:django_db_models_fields_related.py

示例3: __init__

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

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

        class Writer(models.Model):
            name = models.CharField(max_length=255)
            publications = models.ManyToManyField('Publication', blank=True, null=True)

        class Book(models.Model):
            publication = models.ForeignKey(Publication)
            writer = ChainedManyToManyField(
                Writer,
                chained_field="publication",
                chained_model_field="publications",
                )
            name = models.CharField(max_length=255)

        ``chained_field`` is the name of the ForeignKey field referenced by ChainedManyToManyField of the same Model.
        in the examples, chained_field is the name of field publication in Model Book.

        ``chained_model_field`` is the name of the ManyToMany field referenced in the 'to' Model.
        in the examples, chained_model_field is the name of field publications in Model Writer.

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

        """
        try:
            isbasestring = isinstance(to, basestring)
        except NameError:
            isbasestring = isinstance(to, str)
        if isbasestring:
            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.chain_field = chained_field
        self.chained_model_field = chained_model_field
        self.auto_choose = auto_choose
        ManyToManyField.__init__(self, to, **kwargs)
开发者ID:DjangoBD,项目名称:django-smart-selects,代码行数:45,代码来源:db_fields.py

示例4: __init__

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


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