django next and previous button in detail page

I’m trying to create a next and previous button on a single(detail) page. I don’t understand how to make this happen. These are my codes

views.py

def playsong(request, id,slug, tag_slug=None):
beat= Number_beat.objects.get(created_beats=id)
album = Album.objects.get(album_id= id)
albu = Album_beats.objects.filter(album_name= id)
bea=Beats.objects.all()
nextbeat = Number_beat.objects.filter(id__gt = beat.id).order_by(‘id’).first() #.values(‘id’)[:1]
lastbeat = Number_beat.objects.filter(id__lt= beat.id).order_by(‘id’).last()

tag= None
if tag_slug:
    tag = get_object_or_404(Tag,slug=tag_slug)
    beat=beat.filter(tags__in=[tag])




context={
    'beat':beat,
    'nextbeat':nextbeat,
    'lastbeat':lastbeat,
    'album':album,
    'albu':albu,
}

return render(request, 'music/playsong.html', context)

html

    {% if lastbeat %}
        <li class="page-item">
            <a class="page-link" href="{% url 'playsong' lastbeat %}?{{ request.GET.urlencode }}" id="pred">{{ lastbeat }}</a>
        </li>
    {% else %}
        <li class="page-item">
            <a class="page-link" href="{% url 'index' %}" id="pred">home</a>
        </li>
    {% endif %}

    {% if nextbeat %}
        <li class="page-item">
            <a class="page-link" href="{% url 'playsong' %}?next={{ nextbeat|urlencode }}" id="predj">{{nextbeat}}</a>
        </li>
    {% else %}
        <li class="page-item">
            <a class="page-link" href="{% url 'index' %}" id="pred">home</a>
        </li>
    {% endif %}

please can anyone help on Ican do

You’ve shown your templates here, what is being rendered for these pages? What specifically is not working for you?

You want to add a next song and a previous song button ?