예제 #1
0
 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)
예제 #2
0
 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
예제 #3
0
    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)
예제 #4
0
    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)
예제 #5
0
 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)
예제 #6
0
 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()
 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()