Retreive User IP Address and other details through HTML Form

56 views
Skip to first unread message

Stephen olumide

unread,
Jun 3, 2021, 9:17:26 AM6/3/21
to Django users
Hello Everyone,
I need help with my Django web app, see link below
I need the form to display/populate the following:
- Username
- System Name
- IP Address
- MAC Address

The user can fill remaining fields manually:
- System Brand
- System Type
- Model
- Location

I uploaded it on pythonanywhere.com but my code is only picking app host details not picking visitor's details
Please help
Regards

Kasper Laudrup

unread,
Jun 3, 2021, 1:54:35 PM6/3/21
to django...@googlegroups.com
On 03/06/2021 12.04, Stephen olumide wrote:
> Hello Everyone,
> I need help with my Django web app, see link below
> https://caryang.pythonanywhere.com

It would be much more useful if you could link to the source code, or
even better, the relevant snippets instead.

> I need the form to display/populate the following:
> - Username

No problem. That's available as the "user" attribute on the request object.

> - System Name

Not sure what you mean by "system name" but you might get what you want
from either "HTTP_USER_AGENT" or "REMOTE_HOST" in the META dictionary in
the request object. Be aware that these are easily spoofed by the
client, so you shouldn't rely on those being valid.

> - IP Address

Available in "REMOTE_ADDR" in the META dictionary in the request object.
Again, this is trivial to spoof so you cannot rely on this being correct.

> - MAC Address

That's not possible. You might be able to do an ARP lookup if your
client happens to be on the same network as your server and might be
lucky to get a valid reply, but I wouldn't count on it.


Again, that would require the IP address to be correct, which, as
already mentioned, you cannot rely on.

Since you want to host your code on some hosting provider somewhere
else, there's no way you can get that information.

Kind regards,

Kasper Laudrup

OpenPGP_signature

Stephen olumide

unread,
Jun 3, 2021, 4:47:13 PM6/3/21
to django...@googlegroups.com
Wow...thanks for the response. Yes we are all on same network in an organization. I will send view.py and index.html code later, it's 9:46pm here.
Regards

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/j2FQ_AkdX5U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/92153d47-91ec-1946-1f6f-d5378c9b3704%40stacktrace.dk.

sachinbg sachin

unread,
Jun 3, 2021, 11:45:30 PM6/3/21
to django...@googlegroups.com
When we host in server always it shows the our hosted server ip address ,not the users IP address, I tried collecting ip from the request it's giving the hosted server ip address. 

Thanks and regards
Sachin B.G

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF0hcNrybgQdBAVVFS8jvuDfsRVHCRhFubwqX8ncJK2V3aYegA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages