Code Monkey home page Code Monkey logo

Comments (2)

Etilem avatar Etilem commented on June 11, 2024 1

thank you for the comprehensive answer, it works indeed with :

STATIC_TEMPLATES = {
    'ENGINES': [{
        'BACKEND': 'render_static.backends.StaticDjangoTemplates',
        'OPTIONS': {
            'app_dir': 'templates',  # search this directory in apps for templates
            'loaders': ['render_static.loaders.StaticAppDirectoriesBatchLoader'],
            'builtins': ['render_static.templatetags.render_static']
        },
    }],
    'templates': ['landing/home.html']
}

by the way, there's a typo in documentation at line 56 of https://github.com/bckohan/django-render-static/blob/main/doc/source/configuration.rst?plain=1, it says STATIC_TEMPALTES instead of STATIC_TEMPLATES

from django-render-static.

bckohan avatar bckohan commented on June 11, 2024

Hi @Etilem thanks for giving the library a try! By default the static template engine searches for static templates in a directory called static_templates. So if you rename your templates directory to static_templates it should work for you.

Alternatively you can configure the directory loaders will look in. Understand that the static templates engine is a close mirror of the normal templates configuration. This means the STATIC_TEMPLATES setting looks very similar to the TEMPLATES setting, but they are completely separate. STATIC_TEMPLATES controls the static templates rendering (at package or deployment time via renderstatic) and TEMPLATES controls Django's dynamic templates (at serving time via Django's views).

Here is an example configuration that would make renderstatic look in the templates directory instead:

STATIC_TEMPLATES = {
  'ENGINES': [
      'BACKEND': 'render_static.backends.StaticDjangoTemplates',
      'OPTIONS': {
          'app_dir': 'templates',  # search this directory in apps for templates
          'loaders': [
              'render_static.loaders.StaticAppDirectoriesBatchLoader',
           ],
          'builtins': ['render_static.templatetags.render_static']
      },
  ],
  'templates': ['landing/home.html']
}

from django-render-static.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.