views:

25

answers:

2

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
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
A: 

you can also do this using context processors, http://docs.djangoproject.com/en/dev/ref/templates/api/#writing-your-own-context-processors

Ashok