[GeoNode-users] Template extension over multiple apps

gkpetrak gkpetrak at gmail.com
Tue Nov 14 06:49:43 PST 2017


Hello Stefano,


You don't have to name site_base.html or index.html the base templates 
of your apps. You should name them in a way like: app1_base.html. So 
your directory tree will look like this:

-virtual_environment
-geonode
     -geonode
         -templates
             -base.html
             -index.html
-custom_project
     -app1
         -templates
             -app1_base.html (extends site_base.html which extends 
base.html)
             -app1_index.html (if It's required)(extends site_index.html 
which extends index.html)
     -app2
         -templates
-app2_base.html (extends site_base.html which extends base.html)
             -app2_index.html (if It's required) (extends 
site_index.html which extends index.html)


As GeoNode is composed of many apps see for example the directory 
structure of "layers" app


site_base.html and index_base.html is the  base template of your GeoNode 
project in order to customize your site.


Best Regards,

George



On 14/11/2017 02:48 μμ, Stefano.LUONI at ext.ec.europa.eu wrote:
> Hi everyone,
>
> I know that it sounds more of a Django related question, but as a non 
> Django expert I'm a bit confused about the ways to extend templates.
>
> _The problem_
> In a development environment, suppose we have created a new app and 
> suppose we call it *app1*; we can customise the page look by editing 
> *site_base.html *for global parts, *index.html *or other specific 
> templates, knowing that site_base will extend *base.html *from 
> geonode/templates folder, and so on.
> What if we create another custom app and we call it *app2*: how can we 
> define templates that could inherit from what was already defined by 
> *app1*?
>
> The directory tree looks like this:
>
> -virtual_environment
> -geonode
>     -geonode
>         -templates
>             -base.html
>             -index.html
> -custom_project
>     -app1
>         -templates
>             -site_base.html (extends base.html)
>             -site_index.html (extends index.html)
>     -app2
>         -templates
>             -new_template => how to extend site_base.html?
>
> The issue I'm facing is that as soon as I enable context_processors in 
> my settings.py, I get an error because the Geonode base.html template 
> is not found (from extends base.html in 
> geonode/base/templates/geonode_base.html).
> I tried using different configurations with loaders like app_namespace 
> or apptemplates with no luck.
>
> Do you have any suggestions for solving this?
>
> Thanks,
>
> Stefano
>
>
>
>
>
>
> _______________________________________________
> geonode-users mailing list
> geonode-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/geonode-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geonode-users/attachments/20171114/662c3037/attachment.html>


More information about the geonode-users mailing list