Reading and using someones IP address is something I do quite frequently, so I was happy to learn that it is pretty easy to read a visitors meta data in Django. I will explain how to view a visitors IP address, and that should get you started. For information on how to read other information, and a list of everything that is available, you can take a look at
this devhttp page.
In PHP, to read a users IP address, you would look at the specific key in the
$_SERVER variable like this.
$ip_address = $_SERVER['REMOTE_ADDR'];
And here is how to do it in a Django view.
ip_address = request.META['REMOTE_ADDR']
That should get the ball rolling with meta information. If you have any other questions or suggestions, feel free to comment below! Enjoy!
Hey, Shane! I like what you're doing on this blog. I so much would like to see some automated conversion tools, that I went ahead and created the http://php2django.googlecode.com project. Care to join in?
ReplyDelete