[Answer]-How to request URL of previous page visited and store parts of it as a ForeignKey?

1👍

Be aware that the ?P<uniquepageURL> syntax indicates a named group; Django will attempt to match that name to arguments in the view function (see https://docs.djangoproject.com/en/1.7/topics/http/urls/#named-groups).

So, to get that value passed to your view function, simply include a parameter uniquepageURL. Note that means post.pk won’t work as a name; consider post_id as an alternative. (Though I supposed you could use a **kwargs construct and get at the value with kwargs['post.pk']).

That said, if you do need other information from the request URL, I think the value you are looking for is request.path (which presumes your signature is def comment(request, uniquepageURL, post_id) or similar.

Leave a comment