[GeoNode-users] Query recent maps in views.py

Arisandi, Donny (ICRAF) D.Arisandi at cgiar.org
Thu Sep 21 19:30:26 PDT 2017

Hi Paolo, that I was looking for. But in template, how to get the the URL and Image for the map? I tried like below script it did not work. Please advise.

<h4 class="subheading">{% trans "Recent Map" %}</h4>
      {% for content in recent_maps %}
        <div class="col-md-3">
          <div class="recent-box">
            <div class="text-center">
              <a href="{{ map.detail_url }}" title="{{ map.name|escape }}">
                <img src="{{ map.thumbnail_url }}" alt="thumbnail" width="250" height="150">
                <div class="recent-abstract">
                  {{ content.abstract|escape|urlize|linebreaks|safe|truncatechars:250 }}
                <div class="recent-title">{{ content.title|escape|truncatechars:30 }}</div>
      {% endfor %}

-----Original Message-----
From: Paolo Corti [mailto:pcorti at gmail.com] 
Sent: 20 September 2017 20:45
To: Simone Dalmasso
Cc: Arisandi, Donny (ICRAF); geonode-users at lists.osgeo.org
Subject: Re: [GeoNode-users] Query recent maps in views.py

I think Donny would like to see thumbnails of recently update maps.

If this is the case, this can be easily done with:
Map.objects.all().order_by('-last_modified') in the views.py.
Then use map.get_thumbnail_url in the template


On Wed, Sep 20, 2017 at 9:38 AM, Simone Dalmasso <simone.dalmasso at gmail.com> wrote:
> Hi,
> what you need is not trivial. GeoNode doesn't have a model for 
> Thumbnails, they are managed through Links 
> (https://github.com/GeoNode/geonode/blob/2.6.x/geonode/base/models.py#
> L892), but a Link doesn't have a timestamp for its creation, so you 
> would need something to read the files from the disk.
> Maybe the way to go could be to create your own model for recent 
> thumbnails and update their status in the db through a cron celery 
> task. So your view would easily read from it.
> Hope it helps and others ideas are welcome.
> 2017-09-20 10:35 GMT+02:00 Arisandi, Donny (ICRAF) <D.Arisandi at cgiar.org>:
>> Dear all,
>> I need your help to create query in views.py to show recent map thumbnail.
>> Could you show me the sample how to do it?
>> Thank you
>> D
>> _______________________________________________
>> geonode-users mailing list
>> geonode-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/geonode-users
> --
> Simone
> _______________________________________________
> geonode-users mailing list
> geonode-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/geonode-users

Paolo Corti
Geospatial software developer
web: http://www.paolocorti.net
twitter: @capooti
skype: capooti

More information about the geonode-users mailing list