在多个页面中带有(外键)的多个模型表单。姜戈
Multiple model forms with (foreign key) in multiple pages. Django
这是我在 Whosebug 上的第一个问题,请原谅我的错误。
现在,进入正题!
我目前正在用 django 制作网站,它有多个模型链接到一个父模型。现在我想创建一个多页表单来包含所有这些模型。怎么做???
详细问题如下:
models.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
现在我想用所有这些模型创建一个多页表单(比如一个模型表单在一个页面中,然后单击下一步以获取另一个表单)
我该怎么做?
使用 Form Wizard 贡献应用。
更新: 表单向导已从 django 1.8 移至单独的项目 - Django Form Tools。
这是我在 Whosebug 上的第一个问题,请原谅我的错误。
现在,进入正题!
我目前正在用 django 制作网站,它有多个模型链接到一个父模型。现在我想创建一个多页表单来包含所有这些模型。怎么做???
详细问题如下:
models.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
现在我想用所有这些模型创建一个多页表单(比如一个模型表单在一个页面中,然后单击下一步以获取另一个表单)
我该怎么做?
使用 Form Wizard 贡献应用。
更新: 表单向导已从 django 1.8 移至单独的项目 - Django Form Tools。