1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # In this example we're accessing an auth profile (avatar), and a static string in a template.
# First we would need the following environment file (.env)
from environment.standard import AuthProfileGenerator
entries = {
'avatar':AuthProfileGenerator(),
'greeting':'Hello',
}
# views.py
from environment import ctx
from django.shortcuts import render_to_response
def hello(request):
return render_to_response('hello.html',ctx())
# hello.html
<p>{{ env.greeting }}, {{ env.avatar }}</p>
|
More like this
- Accessing Environment Variables in Views by LorenDavie 4 years, 9 months ago
- Use django-admin.py instead of manage.py by whiteinge 4 years, 11 months ago
- Google Charts Templatetags (HTML) by justquick 5 years ago
- monkey-patch django to use jinja2 templates for 404/500 pages and 3rd-party apps by brondsem 4 years, 2 months ago
- Dynamic Backends by LorenDavie 4 years, 7 months ago
Comments