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
我應該怎麼做才能看到我註冊用戶後檢查的值?難道我做錯了什麼 ?