title: Django form to display user attributes
body: <p>I'm having an odd problem that I can't remedy: Django is not displaying any of the user's attributes except for the username when using a form that includes a foreign key attribute between two models.</p>
  
  <p>The associated username is showing up correctly, but none of the other attributes are (first name, last name, email, etc).</p>
  
  <p>Similarly, the debugging print statement that I've placed in the views.py is correctly printing the user's attributes in the terminal output. </p>
  
  <p>Why aren't any of the user's attributes showing up in the html template?</p>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>class UnitGroup(models.Model):
      unit_name = models.CharField(max_length=150, verbose_name='Unit Name')
  
  class UnitUser(models.Model):
      user = models.OneToOneField(User)
      unit = models.ForeignKey(UnitGroup)
      ROLES = ((0, 'Admin'), (1, 'Member'))
      role = models.IntegerField(null=True, blank=True, verbose_name='Role', choices=ROLES)
  
      def __string__(self):
          return self.user.first_name
  </code></pre>
  
  <p><strong>forms.py</strong></p>
  
  <pre><code>class UserGroupForm(forms.ModelForm):
      class Meta:
          model = UnitUser
          fields = '__all__'
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>from units.forms import UnitForm, UnitDetailsForm, UserGroupForm
  from units.models import UnitGroup, UnitDetails, UnitUser
  from django.contrib.auth.models import User
  
  def edit_members(request):
      if request.user.is_authenticated() \
              and request.method == 'GET' \
              and 'unit' in request.GET:
  
          unit_group = request.GET['unit']
          unit_users = UnitUser.objects.filter(unit=unit_group)
          unit_forms = []
  
          for i in unit_users:
  
              # debug
              print(i.user.first_name)
              print(i.user.last_name)
  
              unit_forms.append(UserGroupForm(instance=i))
  
          return render(request, 'units/edit-members.html', {'unit_forms': unit_forms})
  </code></pre>
  
  <p><strong>edit-members.html</strong></p>
  
  <pre><code>{% for form in unit_forms %}
  
      user: {{ form.user }} &lt;br&gt;
      first name: {{ form.user.first_name }}
  
  {% endfor %}
  </code></pre>