title: AttributeError at /map creating folium map in Django
body: <p>I am reading gps coordinates from a postgressql database, and I am using folium to create a map. I use iframe to embed the map in index.html. The data is being read and displayed in index.html, but the embedded map.html throws an error saying ''QuerySet' object has no attribute 'Lat'' - but my recordset does have a field called Lat and I use it in index.html</p>
  
  <p>I am displaying the data (latitude, longitude, a picture taken at those coordinates) in index.html. I've created a model and have data in a postgressql database. I created a function in views.py where I'm looping through the dataset to create markers in a folium map. Then I'm using iframe to embed it in an index.html</p>
  
  <p>views.py</p>
  
  <pre><code>from django.shortcuts import render
  from django.http import HttpResponse
  from .models import PhotoInfo
  import folium
  
  # Create your views here.
  def index(request):
      VarPhotoInfo = PhotoInfo.objects.order_by('DateTaken')
  
      context = {'PhotoInfo': VarPhotoInfo }
  
      return render(request,'natureapp/index.html',context)
  
  def show_map(request):
      #creation of map comes here + business logic
      PhotoInfo1 = PhotoInfo.objects.order_by('DateTaken')
      m = folium.Map([33.571345, -117.763265], zoom_start=10)
      test = folium.Html('&lt;b&gt;Hello world&lt;/b&gt;', script=True)
      popup = folium.Popup(test, max_width=2650)
      folium.RegularPolygonMarker(location=[33.571345, -117.763265], popup=popup).add_to(m)
      fg = folium.FeatureGroup(name = "MyMap")
      for lt, ln, el, fn  in zip(PhotoInfo1.Lat,PhotoInfo1.Lon, PhotoInfo1.DateTaken, PhotoInfo1.PhotoName):
          fg.add_child(folium.Marker(location={float(lt),float(ln)},popup = str(el) +' file: '+fn, icon = folium.Icon(color='green')))
  
      m.add_child(fg)
      str = m.get_root().render()
      context = {'MyMap': str}
  
      return render(request, 'natureapp/map.html', context)
  
  map.html:
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;NatureMapper&lt;/title&gt;
        &lt;/head&gt;
  &lt;h1&gt;Map goes here &lt;/h1&gt;
  {{ my_map  }}
  &lt;/html&gt;
  
  index.html:
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;NatureMapper&lt;/title&gt;
        &lt;/head&gt;
  &lt;h1&gt;Here it is! &lt;/h1&gt;
   {% if PhotoInfo %}
  
    {% for Photo in PhotoInfo %}
  
   &lt;p&gt;there is info.&lt;/p&gt;
     &lt;p&gt; {{ Photo.PhotoName }}&lt;/p&gt;
     &lt;p&gt; {{ Photo.Lat }}&lt;/p&gt;
     &lt;p&gt; {{ Photo.Long }}&lt;/p&gt;
     &lt;p&gt;  &lt;img src="{{ Photo.PhotoImage.url }}" width = "240" alt=""&gt;&lt;/p&gt;
  
  
    {% endfor %}
  
   {% else %}
  
   &lt;p&gt;there is no info.&lt;/p&gt;
   {% endif %}
  
   &lt;iframe id="encoder_iframe" height=95% width="70%" src="{% url 'show_map' %}"&gt;
       &lt;/iframe&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>Index.html displays all the data including the picture fine. 
  <code>show_map</code> has the following error message:</p>
  
  <blockquote>
    <p>AttributeError at /map 'QuerySet' object has no attribute 'Lat'
    Request Method:   GET Request URL:    <a href="http://127.0.0.1:8000/map" rel="nofollow noreferrer">http://127.0.0.1:8000/map</a> Django
    Version:  2.2 Exception Type: AttributeError Exception Value: 
    'QuerySet' object has no attribute 'Lat' Exception
    Location: C:\Users\denjs\Documents\DjangoProjects\NatureMapper2\naturemapper2\natureapp\views.py
    in show_map, line 22 Python
    Executable:   C:\Users\denjs\AppData\Local\conda\conda\envs\mydjangoenv\python.exe
    Python Version:   3.7.2 Python Path:<br>
    ['C:\Users\denjs\Documents\DjangoProjects\NatureMapper2\naturemapper2',
    'C:\Users\denjs\AppData\Local\conda\conda\envs\mydjangoenv\python37.zip',
    'C:\Users\denjs\AppData\Local\conda\conda\envs\mydjangoenv\DLLs',
    'C:\Users\denjs\AppData\Local\conda\conda\envs\mydjangoenv\lib',
    'C:\Users\denjs\AppData\Local\conda\conda\envs\mydjangoenv', 
    'C:\Users\denjs\AppData\Local\conda\conda\envs\mydjangoenv\lib\site-packages',
    'C:\Users\denjs\AppData\Local\conda\conda\envs\mydjangoenv\lib\site-packages\win32',
    'C:\Users\denjs\AppData\Local\conda\conda\envs\mydjangoenv\lib\site-packages\win32\lib',
    'C:\Users\denjs\AppData\Local\conda\conda\envs\mydjangoenv\lib\site-packages\Pythonwin']
    Server time:  Tue, 16 Jul 2019 01:40:33 +0000</p>
  </blockquote>