models.py
class UserProfile(models.Model):
user = models.OneToOneField(User)
security_question = models.CharField('Question', max_length=255, null=True, blank=True)
security_answer = models.CharField('Answer', max_length=255, null=True, blank=True)
phone_daytime = models.CharField('Phone daytime', max_length=50, null=True, blank=True)
phone_mobile = models.CharField('Phone mobile', max_length=50, null=True, blank=True)
work_street = models.CharField('Street', max_length=255, null=True, blank=True)
work_suburb = models.CharField('Suburb', max_length=200, null=True, blank=True)
work_state = models.CharField('State', max_length=100, null=True, blank=True)
work_postcode = models.CharField('Postcode', max_length=20, null=True, blank=True)
work_country = models.CharField('Country', max_length=200, null=True, blank=True)
ビュー.py
def method(request):
''''
profile = UserProfile.objects.get(user=user)
'''''
return render(request,'index.html',{'profile':profile})
データベース フィールドの work_street、work_suburb、work_state、work_postcode、work_country を文字列に変換し、テンプレートでレンダリングする方法。