print profile_form.errors
ショー:
<ul class="errorlist"><li>user<ul class="errorlist"><li>This field is required.</li></ul></li></ul>
コード:
def update(request):
user = get_object_or_404(User, pk=request.user.id)
profile = get_object_or_404(UserProfile, user=user)
if request.method == 'POST':
user_form = RegistrationForm(request.POST, instance=user)
profile_form = ProfileForm(request.POST, request.FILES, instance=profile)
---
class ProfileForm(forms.ModelForm):
address = forms.CharField(required=False, max_length=250, widget=forms.Textarea(attrs={'rows': 2}))
class Meta:
model = UserProfile
---
class UserProfile(models.Model):
...
country = models.ForeignKey(Country, default=1)
city = models.ForeignKey(City, default=1)
user = models.OneToOneField(User)
プロファイルはすでにユーザーに割り当てられているので、どうすればそれを回避できますか。