Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Nov. 24, 2005 10:20:31

p.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Standalone template language


I wonder if it's possible to use Django's template engine outside of
Django.

I tried to import Template from django.core.template but Python
interpreter complains about undefined DJANGO_SETTINGS_MODULE.

Thanks

Offline

#2 Nov. 24, 2005 16:59:29

Cheng Z.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Standalone template language


It's possible, based on my limited knowledge of Django. I think suchusage is more like using a Python library.In your case, you need to set the environment variableDJANGO_SETTINGS_MODULE as shown in tutorial 1, e.g. exportDJANGO_SETTINGS_MODULE=myproject.settings- Cheng

On Nov 24, 2005, at 6:20 PM, paolo wrote:I wonder if it's possible to use Django's template engine outside of
Django.

I tried to import Template from django.core.template but Python
interpreter complains about undefined DJANGO_SETTINGS_MODULE.

Offline

#3 Nov. 24, 2005 17:31:27

P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Standalone template language


2005/11/24, Cheng Zhang <>:
>
> It's possible, based on my limited knowledge of Django. I think such
> usage is more like using a Python library.
> In your case, you need to set the environment variable
> DJANGO_SETTINGS_MODULE as shown in tutorial 1, e.g. export
> DJANGO_SETTINGS_MODULE=myproject.settings

Hi Cheng Zhang, perhaps my request wasn't clear enough. I'd like to
use Django's template language in an application made in plain Python.
Django doesn't appear at all in this scenario, so setting
DJANGO_SETTINGS_MODULE has not much sense, because I'm not working
with a Django project.

Today I've been able to use the template language on its own with a
simple "trick". My solution works well enough for my modest needings
(though it is far from being an acceptable solution), but probably it
will present side effects in some situation and *for sure* will limit
the flexibility of Django's template system (i.e., it is not possible
to define custom filters/tags)

I hope some Django's developer or hacker will hear my voice and give
some help ;-)

Thanks for your attention.

Offline

#4 Nov. 25, 2005 02:18:51

Kenneth G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Standalone template language


On Thursday 24 Nov 2005 11:01 pm, Paolo wrote:
> Today I've been able to use the template language on its own with
> a simple "trick".

what is the trick?

--
regards
kghttp://www.livejournal.com/users/lawgontally ho!http://avsap.org.inಇಂಡ್ಲಿನಕ್ಸ வாழ்க!

Offline

#5 Nov. 25, 2005 07:57:57

p.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Standalone template language


The first import in django/core/template/__init__.py wants to obtain
DEFAULT_CHARSET and TEMPLATE_DEBUG from the settings file. Being
DJANGO_SETTINGS_MODULE not set, an EnvironmentError exception is
raised. If you handle this exception with try/except, defining yourself
default values for DEFAULT_CHARSET and TEMPLATE_DEBUG, you have found a
(rude) way to change the intended behaviour.

Of course, as already said, this is not an acceptable solution,
because: 1) in this way the default charset and template debug settings
are hardcoded; 2) still worst, you can't extend the template language
with your tags and filters, as their definitions live in a package at
the same level as models, views, etc., and so it is coupled to an
application.

Perhaps, a valid solution would require changes at a deeper level!

Thanks for your attention.

Offline

Board footer

Moderator control

Enjoy the 23rd of April
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support