Answer the question
In order to leave comments, you need to log in
Django how to redirect to a page with pagination?
I work with Django. There is a page with different groups of photos, broken by a paginator. Each group of photos has a button with redirection to the page with all the photos of this group (only the first 5 photos of each group are displayed on the main page). This page is also broken by a paginator for convenience.
Question: how to make a redirect to the right part of the page paginator with all groups of photos? I understand that the desired address can be obtained through request.META.get('HTTP_REFERER')
. But the problem is that due to pagination on a page with a specific group, a link to the previous part of the paginator of this group will return (if the user goes to at least the second page with photos). Where to get or how to save information about which number of the main page the user came from?
Answer the question
In order to leave comments, you need to log in
Using HTTP_REFERER is not an option, it is at least not reliable.
When you go from a page with a group of photos, you can remember the number of the page from which you went.
To do this, you can use cookies, or add a parameter to paginator' for example grp_page_num (so as not to lose it during transitions).
In general, I would advise you to change your approach somewhat.
If you don’t have a task to have separate pages as you describe, then it’s better not to go to the page with all the photos in the group, but simply upload the photo when scrolling the page in the way that, for example, social networks do. They also have feeds without a paginator, they just load a new portion of posts when you scroll to the end. Alternatively, you can make a "more" button and upload the next portion of the photo.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question