多个页面中包含(外键)的多个模型表单。姜

2024-09-30 18:19:08 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我在StackOverflow上的第一个问题,请原谅我的错误。在

现在,回答这个问题!在

我目前正在django制作网站,它有多个模型链接到一个父模型。现在我想创建一个包含所有这些模型的多页表单。怎么做???在

具体问题如下:

模型.py

class Profile(models.Model):

    user = models.OneToOneField(User)

    first_name = odels.CharField(
        max_length=255, validators=ONLY_LETTERS_VALIDATOR)
    last_name = odels.CharField(
        max_length=255, validators=ONLY_LETTERS_VALIDATOR)

    # And some other fields

class YMHTMobile(models.Model):

    profile = models.ForeignKey(Profile)

    mobile = models.CharField(max_length=10, validators=ONLY_DIGITS_VALIDATOR)

    is_active = models.BooleanField(default=True)

    def __unicode__(self):
        return '%s' % self.mobile

    class Meta:
        verbose_name_plural = 'Mobile Details'

# some more models with foreign key as profile

现在,我想创建一个包含所有这些模型的多页表单(比如一个页面中的一个模型表单,然后单击next以获得另一个表单)

我该怎么做??在


Tags: name模型表单onlymodelmodelsprofilelength