How to save Request URL from inspector in Django Model
I'm trying to implement a web application in which the user fills out a form and separately there is a form that the user fills out and selects a route on the map.
I use Mapbox for this. In HTML it looks like I have a separate form in the form
element and a separate map in the div element. When I built a route in the inspector, I find a processed request with the GET method and the Request URL.
My question is how to save this URL request together with the form, or at least separately? How do I even save this URL request to the Django Model.
Part from my model.py:
:
class Route(models.Model):
route_name = models.CharField(max_length=50)
lvl = models.IntegerField(default=0)
about = models.TextField(max_length=1500)
total_distance = models.IntegerField(default=0)
country = models.ForeignKey(Country, on_delete=models.CASCADE)
def __str__(self):
return self.route_name
def __str__(self):
return self.about
class RoutesURL(models.Model):
url = models.CharField(max_length=1000)
def __str__(self):
return self.url
And my views.py
:
def getForm(request):
form = RouteForm()
if request.method == 'POST':
form = RouteForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('home')
return render(request, 'routes_form/route_form.html', {'form': form})