title: How to use data from postgresql in django?
body: <p>I have switched from <code>sqlite</code> to <code>postgresql</code> following <a href="https://stackoverflow.com/questions/3476606/django-what-are-the-best-practices-to-migrate-a-project-from-sqlite-to-postgres">Django: What are the best practices to migrate a project from sqlite to PostgreSQL</a> the fourth answer.</p>
  <p>Here are my updated settings:</p>
  <pre><code>DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.postgresql_psycopg2',
          'NAME': 'scraper',
          'USER':'user',
          'HOST':'localhost',
          'PORT':'5432',
      }
  }
  </code></pre>
  <p>However, I cannot seem to find/grab any of the data from my database. Here's some example data from the database:</p>
  <p><a href="https://i.stack.imgur.com/hWBNYm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hWBNYm.png" alt="enter image description here" /></a></p>
  <p>The migration works successfully with my postgres as I have all the tables:
  <a href="https://i.stack.imgur.com/y7uznm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y7uznm.png" alt="enter image description here" /></a></p>
  <p><code>item</code> is a table that was in the database before migration. I want to be able to access the data in <code>item</code> and use that to update my django model. How can I do this?</p>
  <p>I have tried</p>
  <pre><code>python manage.py dumpdata
  </code></pre>
  <p>But get this:</p>
  <pre><code>[{&quot;model&quot;: &quot;auth.permission&quot;, &quot;pk&quot;: 1, &quot;fields&quot;: {&quot;name&quot;: &quot;Can add log entry&quot;,
   &quot;content_type&quot;: 1, &quot;codename&quot;: &quot;add_logentry&quot;}}, {&quot;model&quot;: &quot;auth.permission&quot;, &quot;pk&quot;: 2,
   &quot;fields&quot;: {&quot;name&quot;: &quot;Can change log entry&quot;, &quot;content_type&quot;: 1, &quot;codename&quot;:
   &quot;change_logentry&quot;}}, {&quot;model&quot;: &quot;auth.permission&quot;, &quot;pk&quot;: 3,
  ... 
  </code></pre>
  <p>I wanted to upload that data based on my current app:
  models.py</p>
  <pre><code>from django.db import models
  
  class Cruises(models.Model):
      title = models.CharField(max_length=200)
      #ship_name = models.CharField(blank=True, null=True,max_length = 200)
  
      def __str__(self):
          return self.title
  
  </code></pre>
  <p>views.py</p>
  <pre><code>from django.shortcuts import render
  #from .models import Cruises
  from .models import Cruises
  def basic(request): 
      #form_destination =  Cruises
      long_list = Cruises.objects.values('title')
      return render(request, 'cruise_control/basic.html', context = {'long_list':long_list})
  </code></pre>
  <p>urls.py</p>
  <pre><code>from django.urls import path
  from . import views
  
  urlpatterns = [
      path('',views.basic, name = 'basic')
  ]
  </code></pre>
  <p>basic.html</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset=&quot;utf-8&quot;&gt;
      &lt;title&gt;Cruises&lt;/title&gt;
    &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt; Cruise Control &lt;/h1&gt;
  
  
  &lt;form action=&quot;/action_page.php&quot;&gt;
    &lt;label for='destination'&gt;Destination&lt;/label&gt;
    &lt;input type=&quot;text&quot; list=&quot;destination&quot; /&gt;
    &lt;datalist id=&quot;destination&quot;&gt;
    {% for lng_l in long_list %}
    &lt;option&gt;{{lng_l.title}}&lt;/option&gt;
    {% endfor %}
    &lt;/datalist&gt;
    &lt;!label for=&quot;cruisetime&quot;&gt;Departure date&lt;/label&gt;
    &lt;!input type=&quot;date&quot; id=&quot;cruisetime&quot; name=&quot;cruisetime&quot; min={{dep_l.departureDate}}&gt;
    &lt;!input type=&quot;submit&quot;&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>However, because it grabs none of the data I get the following without any values in the drop-down:
  <a href="https://i.stack.imgur.com/qku18.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qku18.png" alt="enter image description here" /></a></p>