Tutorial :Django template tag to return IP Address?



Question:

I need to write a simple Django template tag that will display the user's IP Address?


Solution:1

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.


Solution:2

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


Solution:3

If you did it with javascript, you could just use this:

jsonip.com


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »