Hello,
I am trying to redirect the user to details page of an item only if he is logged in. I read a lot of topics, even chatGPT could helped me. I created even a custom LoginView but it still redirect the user not to the details page of the item, but to the home page. Here is some code:
This is the html for the item. At the end I have a button for going to details page.
{% if itemshop_list %}
<h2 class="title">Items for sale</h2>
<div class="custom-main">
{% for item in itemshop_list %}
<div class="cards">
<div class="card">
<div class="img">
<img src="{{ item.main_photo.url }}" alt="No Photo"/>
</div>
<div class="text">
<h2>
{{ item.title }}
</h2>
<ul>
<li>Price: {{ item.price }} BGN</li>
</ul>
<button><a href="{% url 'details_petshop' item.pk %}?next={{ request.path }}">Details</a></button>
</div>
</div>
</div>
{% endfor %}
</div>
{% else %}
The main settings.py. For urls I am have only one for using sign up format. But I a have custom log in template.
LOGIN_REDIRECT_URL = 'home'
AUTH_USER_MODEL = 'accounts.CustomUser'