鉴于models.py中的以下模型:
class Profile(models.Model):
name = models.CharField(max_length=30)
email_address = models.CharField(max_length=30)
password = models.CharField(max_length=30)
preferences = models.OneToOneField("Preferences")
def __unicode__(self):
return u"%s" % self.name
class Preferences(models.Model):
likes_hugging = models.BooleanField(default=False)
despises_men = models.BooleanField(default=False)
现在forms.py中的以下形式...
class PreferencesModelForm(forms.ModelForm):
class Meta:
model = Profile
fields = ("preferences",)
...产生以下结果:
但是我如何得到以下结果呢?