I have the following models.py
class UserProfile(models.Model):
user = models.OneToOneField(User)
url = models.URLField(blank=True)
address=models.CharField(max_length=60)
location = models.CharField(max_length=30)
join_date = models.DateField(auto_now_add=True)
I have the following forms.py
class UserForm(ModelForm):
class Meta:
model = UserProfile
I have the following views.py
def login_temp(request):
form = UserForm()
c = RequestContext(request, {
'form': form,
})
return render_to_response('registration/login.html', c)
In my template (login.html), how do I access fields of the django-defined User class. I'm currently using the syntax below. With this syntax, the "address" input field appears in my template, but the "username" input field does not
<form action="/accounts/register/" method="POST">
<label class="control-label" for="id_address">Address</label>
{{ form.address }}
<label class="control-label" for="id_username">Username</label>
{{ form.username }}
</form>
I tried doing {{ form.user.username }}
, but that didn't work either. What am I doing wrong? How do I get get the username field to appear in my template? FYI, the variable username is defined in the User Model. The User model is a "library" that is pre-defined with Django.