I need to write a simple Django template tag that will display the user's IP Address?
A:
You need to take the information from the request (via the view function) in order to present it on a template.
You can't trivially write a custom tag since the IP address must come from the request.
S.Lott
2010-08-05 01:22:18
I wanted to add this globally to all templates, but some views like /accounts/login/ from auth don't have a request object available.
MikeN
2010-08-05 01:27:16
A:
you can also do this using context processors, http://docs.djangoproject.com/en/dev/ref/templates/api/#writing-your-own-context-processors
Ashok
2010-08-05 02:20:16