示例#1
0
    def _getRelatedFieldInfo(self, field: ManyToOneRel):
        relatedField = field.field
        originalHelpText = relatedField.help_text
        _, tableConf = TableNode._getTableInfo(originalHelpText)
        helpText, formInfo = Form._getFormInfo(originalHelpText)
        if not formInfo.related:
            return None, None

        relatedName = field.get_accessor_name()
        logger.debug('relatedName=========== %s', relatedName)
        # name = field.name
        tableConf.name = relatedName
        tableConf.cname = field.related_model.__cname__
        tableConf.field = field
        return relatedName, tableConf
示例#2
0
 def ___handleFieldForManyToOneRel(self, field: ManyToOneRel):
     relatedField = field.field
     originalHelpText = relatedField.help_text
     helpText, formInfo = Form._getFormInfo(originalHelpText)
     if not formInfo.related:
         return
     choices = []
     relatedName = field.get_accessor_name()
     if self.filling:
         relatedData = getattr(self.queryset, relatedName).all()
         logger.debug("relatedData======= %s ", relatedData)
         for i in relatedData:
             choices.append((i.id, i))
     formInfo.formType = 'multiReleted'
     formInfo.choices = choices
     formInfo.name = relatedName
     formInfo.cname = field.related_model.__cname__
     formInfo.label = str(field.related_model._meta.label).lower()
     return formInfo