# In this toy example we're logging information about a user profile (the 'avatar') and request parameters.
# views.py
from django.shortcuts import render_to_response
from environment import env
import logging
log = logging.getLogger('environ_test')
def test_view(request):
log.debug('Logging request from avatar %s using params %s' % (str(env.avatar),str(env.params)))
return render_to_response('test.html',{})
# to make this work, we would need to make the following environment file (.env)
from environment.standard import RequestParameterGenerator, AuthProfileGenerator
entries = {
'avatar':AuthProfileGenerator(), # gets the auth profile model instance associated with the current user
'params':RequestParameterGenerator(), # gets the request parameters as a dictionary
}
Comments