title: How to run tests in django using database with data?
body: <p>I want to test my views using data from postgres localhost database (with already loaded data). I'm using tox with pytest and pytest-django.</p>
  
  <p>My question:
  How to set up / connect to local database to get all the data model schema and data itself? Or maybe it is better to use factory_boy? Or to load whole data from .sql script (if yes, how)?</p>
  
  <p>Example of my test:</p>
  
  <pre><code>def test_foo_view(custom_client_login):
      response = custom_client_login.get('/foo/bar/123/')
  
      assert response.status_code == 200
      assert 'Transaction no. 123' in response.content
  </code></pre>
  
  <p>But instead of getting status code 200 I get 404, which points that no data is in test database. But when I lunch <code>runserver</code> and go to that view <code>('localhost:8000/foo/bar/123/')</code> I will get status 200 and html webpage with some data.</p>
  
  <p>Please help!</p>
  
  <hr>
  
  <p>I'm using:</p>
  
  <ul>
  <li>Django==1.7.11</li>
  <li>pytest==3.0.6</li>
  <li>pytest-django==3.1.2</li>
  <li>tox==2.6.0</li>
  </ul>