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

Popular posts from this blog

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

java - Reading data from multiple zip files and combining them to one -