Django redirect after logout
<p>I'm using Django and to authenticate my user, I have a custom OAuth2 provider. I had to write the login and logout view myself because they are doing some very specific things.</p>

<p>I would like to be redirected to the same url after logout. If you are on a page that require to be authenticated, I would like to redirect to the homepage. I didn't find any resource to know if a view/endpoint is using the decorator <code>login_required</code> </p>

<p>Sure, just use query string parameter <code>next</code>, e.g.: </p>

<pre><code>&lt;a href="{% url 'users:user_logout' %}?next={% url 'some_url' %}"&gt;Log out&lt;/a&gt;
</code></pre>

<p>The rest is only a matter of arranging template hierarchy, so you will use different urls in different templates without repetition.</p>

python django