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 3 years, 6 months ago
- showing environment variables in the django admin by tonemcd 2 years ago
- Rails-like environments using Django by ElfSternberg 2 years, 3 months ago
- monkey-patch django to use jinja2 templates for 404/500 pages and 3rd-party apps by brondsem 2 years, 11 months ago
- Use django-admin.py instead of manage.py by whiteinge 3 years, 8 months ago
Comments