在Django admin中动态更新内容

时间:2016-02-12 15:53:37

标签: django

我有一个django管理仪表板,我可以在其中添加动画。对于每个动画,我首先需要在下拉菜单中选择动画类型,例如'背景'。我希望在“背景”背景下显示特定字段。被选中。现在,如果我选择选择' GOAL'键入一个不同的字段必须出现等...

我这样开始试图改变Charfield的默认值但暂时没有成功......

class Sequence(models.Model):

BACKGROUND = 'BACKGROUND'
SEQUENCE = 'PRODUCT'
INTROLOOP = 'INTROLOOP'
GOAL = 'GOAL'
FOREGROUND = 'FOREGROUND'
TEST = ''

ANIMATION_TYPE = (
    (BACKGROUND, 'BACKGROUND'),
    (SEQUENCE, 'PRODUCT'),
    (INTROLOOP, 'INTROLOOP'),
    (GOAL, 'GOAL'),
    (FOREGROUND, 'FOREGROUND'),
)

titre_CmdiLayer = models.CharField(max_length=5,
                                  choices=ANIMATION_TYPE,
                                  default=BACKGROUND)

if titre_CmdiLayer.NEED_TO_GET_THE_VALUE_OF_THE_CHARFIELD == 'BACKGROUND' :
    TEST = 'BACKGROUND'
else :
    TEST = 'SOMETHINGELSE'

titre_sequence = models.CharField('Name', max_length=50, default=TEST, unique=True)
pub_date_sequence = models.DateTimeField('Date & Time')
def __str__ (self):
    return self.titre_sequence

如果有人有想法?非常感谢提前!

0 个答案:

没有答案