title: How to query Django model from views.py file?
body: <p>I have a model named Search in my models.py file. I have made migrations and everything is working totally fine except one problem. In my views.py file I have created one variable called var1 which queries "search_query" field into the database, but unfortunately, it couldn't assign that variable.
  Please help me how to access my model to work this line,</p>
  
  <pre><code>var1 = Search.objects.latest('search_query')
  </code></pre>
  
  <p>Here is my models.py file,</p>
  
  <pre><code>from django.db import models
  
  class Search(models.Model):
      search_query = models.CharField(max_length=64)
  </code></pre>
  
  <p>views.py file,</p>
  
  <pre><code>from django.shortcuts import render, redirect
  import requests
  from git_profile.forms import SearchForm
  from git_profile.models import Search
  
  def index(request):
      var1 = Search.objects.latest('search_query')
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>I want to replace 'var1' with this replacement 
  <code>python 
  user_profile = requests.get('https://api.github.com/users/{0}'.format(str(v‌​‌​ar1))) 
  content = dict() 
  content['user'] = user_profile.json()
  </code>
  but var1 can not be replaced by replacement field and API gives me weird error </p>