Monday, October 10, 2011

Re: Viewing IP address in the login screen, using Django authentication

Hi Peter,

You need to be using the RequestContext middleware - see 'option #1' on the following:


Once you've got that, you can then use {{request.META}} within your templates.

There is also a how to here, which shows the 'ip_address' as an example.


But in my personal opinion (in this particular example) using an additional processor is a bit pointless (unless the header is dynamic, in which case you'd use middleware anyway :X)

Hope this helps.

Cal

On Mon, Oct 10, 2011 at 11:17 AM, peter-ctp <peterrr73@googlemail.com> wrote:
Folks
I am using the standard django authentication to allow people access
to various web resources.  I manage the password/username logins
through the template login.html file and almost everything works fine.

However: I would like to show the IP address of the user's computer,
as it is seen by the django authentication module.  That is: the IP
address returned by request.META.get('REMOTE_ADDR') in the standard
django request process.  How can I show this somehow in the screen
seen by the user? (the easiest would to be able to write this directly
into the  login.html script, something like..
<p>Your IP address is {{ipaddress}}</p>
or
<p>Your IP address is {{form.ipaddress}}</p>

Help!

Peter

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment