AleksandrAtr / darianna-creative

DaRianna Creative is a fictional website created for educational purposes as part of the Code Institute 4_P course's Milestone Project 4.
0 stars 1 forks source link

Solve the "Keep Shopping" link so it directs the user back to the page it came from. #24

Open AleksandrAtr opened 6 months ago

AleksandrAtr commented 6 months ago

The bag is fixed by following two steps:

  1. Amend the product_display.html View link by adding a query paramater '?next={{ request.path }}' This adds a query parameter named "next" with the value set to the current page's URL (request.path)
  2. In the product_detail.html, use the following structure to retrieve the previous page from the 'next' query:
> {% if request.GET.next %}
>     <a href="{{ request.GET.next }}" class="btn btn-outline-black rounded-0 mt-5">
>         <span class="icon">
>             <i class="fas fa-chevron-left"></i>
>         </span>
>         <span class="text-uppercase">Keep Shopping</span>
>     </a>
> {% else %}
>     <a href="{% url 'home' %}" class="btn btn-outline-black rounded-0 mt-5">
>         <span class="icon">
>             <i class="fas fa-chevron-left"></i>
>         </span>
>         <span class="text-uppercase">Keep Shopping</span>
>     </a>
> {% endif %}
AleksandrAtr commented 6 months ago

The bag still needs to be resolved. If a product is added to the bag, the Keep Shopping link returns the user to the home page.