从Django中的另一个应用程序提供下拉列表选项

时间:2019-05-15 07:48:54

标签: django

我在Django中有不同的应用程序: 项目 用户管理员 ProjectUserXref->在此,我要从“项目”应用程序中提取项目值的下拉列表,并从“用户”应用程序中提取用户的列表,并允许用户将可用项目映射到可用用户。

我有两个不同的表,分别称为Project和UserMaster,其中分别有Projects列表和Users列表。到目前为止,它们都没有通过外键连接。

class Project(models.Model):
        JIRAID = models.CharField(max_length=20,null=True)
        projectID = models.AutoField(primary_key=True)
        projectName = models.CharField(max_length=100)
        projectDescription = models.CharField(max_length=100)
        projectStartDate = models.DateField()
        projectEndDate = models.DateField()
        projectEstimatedLOE = models.IntegerField()
        createdBy = models.CharField(max_length=30)
        createdAt = models.DateTimeField(default=datetime.datetime.now,null=True,blank=True)
        updatedAt = models.DateTimeField(default=datetime.datetime.now,null=True,blank=True)


class UserMaster(models.Model):
    userID = models.AutoField(primary_key=True)
    userName = models.CharField(max_length=100)
    domainID = models.CharField(max_length=30)
    Department = models.CharField(max_length=30)
    Role = models.CharField(max_length=30)
    createdBy= models.CharField(max_length=10)
    createdAt = models.DateTimeField(default=datetime.datetime.now, null=True, blank=True)
    updatedAt = models.DateTimeField(default=datetime.datetime.now, null=True, blank=True)

class ProjectUserXref(models.Model):
        projectID = models.IntegerField()
        projectName = models.CharField(max_length=50)
        userID = models.IntegerField()
        domainID = models.CharField(max_length=30)
        createdBy = models.CharField(max_length=30)
        createdAt = models.DateTimeField(default=datetime.datetime.now, null=True, blank=True)
        updatedAt = models.DateTimeField(default=datetime.datetime.now, null=True, blank=True)

在“ ProjectUserXref”表的“ projectID”和“ projectName”列中,我应该分别从“ Project”表的“ projectID”和“ projectName”列中获取值。和“ userID”和“ domainID”列值应从“ UserMaster”表的“ userID”和“ domainID”中获取。

0 个答案:

没有答案