python - Django: getting previous url -
i have post model requires category before being added database, , want category generated automatically. clicking addpost button takes different page , category determined taking part of previous page url.
is there way previous page url string?
thanks
edit: have added addpost button here.
<aside class="addpost"> <article> <form action="/forum/addpost"> <input type="submit" name="submit" value="add post"/> </form> </article> </aside>
you can using self.request.meta['http_referer']
, exist if tab previous page website, else there no http_referer
in meta dict
. careful , make sure using .get()
notation instead.
# returns none if user came website referer = self.request.meta.get('http_referer')
Comments
Post a Comment