I am trying to build a Django web application that will store internal tracking metrics (along with doing it's own work). I have so far created models to get API hit counters. I want to check from which location user accessed my application. For that purpose I have to store data in GeoDjango Model.
from django.contrib.gis.db import models
class AccessLocation(models.Model):
location = g_models.PointField()
user = models.ForeignKey(User,on_delete=models.PROTECT)
class Meta:
abstract = True
db_table = "location_info"
Now I want to capture User's location when they access my views and store in data-base. Is there any django/pythonic way to do it? For eg: hidden form fields that captures user location (latitude and longitude)? EDIT: I have found how to fetch user's location (if they allow). The question is how do I store them in django model/form?