0
我在我的表单中创建了一个广播字段,注册用户后我看不到他检查的内容。Django单选按钮值不是呈现
user.html:
<p>{{ user.profile.name }}</p>
<p>{{ user.profile.email }}</p>
<p>{{ user.profile.choices }}</p> #not rendering anything, can't see the value after I logged in
<p>{{ user.choices }}</p> #(just in case) not rendering value
这里是我的代码:
models.py:
class Profile(models.Model):
user = models.OneToOneField(User)
email = models.EmailField()
name = models.CharField(max_length=20, blank=True, null=True)
forms.py
from utilisateur.models import Profile
class MyRegistrationForm(forms.ModelForm):
CHOICES=[('clients','Je cherche une secretaire.'), ('secretaires','J\'offre mes services.')]
choices = forms.ChoiceField(required=True, choices=CHOICES, widget=forms.RadioSelect())
class Meta:
model = Profile
fields = ("name", "email", "choices")
def save(self, commit=True):
user = super(MyRegistrationForm, self).save(commit=False)
user.choices = self.cleaned_data['choices']
if commit:
user.save()
return user
我应该怎么做才能看到我注册用户后检查的值?难道我做错了什么 ?