Giter Site home page Giter Site logo

Comments (3)

jezdez avatar jezdez commented on May 30, 2024

Hm, actually that's possible today, just use django.template.loader.render_to_string directly, see the following example:

[../example] git:develop env:dbtemplates $ ./manage.py shell

In [1]: from dbtemplates.models import Template

In [2]: t = Template(name='test.html', content="{% firstof var 'hello' %}")

In [3]: t.save()

In [4]: from django.template.loader import render_to_string

In [5]: render_to_string('test.html', {})
Out[5]: u'hello'

In [6]: render_to_string('test.html', {'var': 'good bye'})
Out[6]: u'good bye'

The template loader of dbtemplates is automatically used when render_to_string looks for the template you ask it to render -- querying the Template model in the process.

from django-dbtemplates.

selwin avatar selwin commented on May 30, 2024

Doh, now that you mentioned it, it's so obvious because render_to_string use the same template loading mechanism as render_to_response.

I feel dumb now -_-

Thanks for your help!

from django-dbtemplates.

jezdez avatar jezdez commented on May 30, 2024

Sorry, didn't mean to make you feel dumb. Glad I could help! :)

from django-dbtemplates.

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.