title: How to load an instance in Django ModelForms
body: <p>I am using Django's user model.</p>
  
  <p>How do I get a Django ModelForm to prepopulate values in a template? I know I have to use the instance for that form, but where am I going wrong below:</p>
  
  <p>models.py:</p>
  
  <pre><code>class Site(models.Model):
     user = models.ForeignKey(User, )
     site_name = models.CharField(max_length=128, blank=False, null=False)
  </code></pre>
  
  <p>forms.py:</p>
  
  <pre><code>class SiteForm(forms.ModelForm):
        class Meta:
              model = Site
              fields = '__all__'
  </code></pre>
  
  <p>views.py:</p>
  
  <pre><code>def settings(request):
  
      site_profile = Site.objects.get(user=request.user)
  
      if request.method == "POST":
          form = SiteForm( instance=site_profile )
              if form.is_valid():
                  form.save()
  
                  return redirect('dashboard_home')
  
          else:
              form = SiteForm()
  
          return render(request, "dashboard/settings.html", {'form': form })
  </code></pre>
  
  <p>This code returns the page with no errors, however does not prepopulate the form fields with values from the database. </p>
  
  <p>I can only assume the <code>instance</code> is not loading correctly?</p>