title: How to prepopulate data from database to a django form
body: <p>I am trying to prepopulate the values from my database into the django form. I tried to pass the object instance from model.py but I wasn't able to render the value. Is there a better way to render it?</p>
  
  <p>Here is my code:</p>
  
  <p><strong>view.py</strong></p>
  
  <pre><code>class myview(TemplateView):
      def get(self,request):
          userinfo = UserInfo.object.get(id=1)
          form = UserForm(form)
          return render(request,'user.html',{'form':form})
  </code></pre>
  
  <p><strong>template.html</strong> </p>
  
  <pre><code>{{form.username}}
  {{form.address}}
  </code></pre>
  
  <p>It throws the error :</p>
  
  <blockquote>
    <p>User object has no attribute 'get'</p>
  </blockquote>
  
  <p>Thanks in advance</p>