view to be dynamically directed to the single page generated by Paginator

Hi everyone, I’m a new developer in Django.

I have a project with an app: “perfume” I have a single view with paginator (numeric index) “one” I have a total view “perfumes”

I want the records of the “name” field of the “all” model in the total view to be dynamically directed to the single page generated by paginator (example: localhost:8000/uno/?page=1)

# my models.py
class Perfume(models.Model):
    name = models.ForeignKey(Name, on_delete=models.CASCADE)
    class Meta:
        ordering = ['name']
        verbose_name_plural = "Perfumes"
    def __str__(self):
        return str(self.name)

class Name(models.Model):
    class Meta:
        verbose_name_plural = "Names"
    name = models.CharField(max_length=50)
    def __str__(self):
        return str(self.name)    
# my view
def all(request):
    perfumes = Perfume.objects.order_by('name')
    return render(request, 'perfumes/perfumes.html', {'perfumes': perfumes})

def uno(request):
    perfumes = Perfume.objects.all().order_by('name')
    paginator = Paginator(perfumes, 1)  # Show 1 posts per page

    page_number = request.GET.get('page')
    try:
        page_obj = paginator.get_page(page_number)
    except PageNotAnInteger:
        page_obj = paginator.page(1)
    except EmptyPage:
        page_obj = paginator.page(paginator.num_pages)

    context = {'page_obj': page_obj}
    return render(request, 'one.html', context) 
# my urls app
urlpatterns = [
    path('', views.perfumes, name='perfumes'),
    path('one/', views.one, name='one'),
]
# my urls project
urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('perfumes.urls')),
]

thanks to anyone who helps me!!

Welcome @offlinem !

This is really an inefficient way of trying to do this.

To do this the “Django Way”, your “all” view would render the list of elements where each element has the link to the url for uno with a parameter identifying which Perfume object to render.

The Official Django Tutorial covers this technique in sections 3 and 4. (If you haven’t worked your way through the official tutorial yet, you should. It demonstrates a number of common patterns that you should be familiar with.)