1

I have created a small app in python with django, that contains registration and logging.I want to get the user logged in place and time in python.How to find this user current location.Thanks in advance

Mulagala
  • 8,231
  • 11
  • 29
  • 48
  • possible duplicate of [Django, Retrieve IP location](http://stackoverflow.com/questions/2218093/django-retrieve-ip-location) – sundar nataraj Jun 30 '14 at 12:58

1 Answers1

1

You can trigger a signal after a user authenticates.

For example:

from django.contrib.auth.signals import user_logged_in

log_user_info(sender, user, request, **kwargs):
    ip = request.META.get('REMOTE_ADDR', None)
    log_time = datetime.datetime.now()
    ...

Checkout the signals documentation for more info.

Hope this helps.

chirinosky
  • 4,438
  • 1
  • 28
  • 39