List with link to details from MySQL table

Django Django MySQL Database Display rows

Our Listing page output is here

Alex John
My John Rob
Tes Qry
Big John

On click of the link we will get output like this.

7,My John Rob,Five,78,male

Connecting to

To execute our model and display records we must add our function to file.
from django.urls import include, path
from.import views

urlpatterns = [
When we use above url, our url page inside student app will run using display function.
def display(request):
    id=request.GET.get('id', 'Not available')
    if(id != 'Not available'):
        return render(request,'details.html',{'st':st})
        return render(request,'list.html',{'st':st})
Here we can see if the value of id is not available ( id='Not available' ) then list.html is used and if id value is available then details.html is used.

Learn how to collect query string data here.
We used st=student.objects.all().order_by('id')[5:10] to generate one QuerySet with records from id 6 to 10, this line can be changed to get different set of records by using filters.
Different filters and string matching for getting QuerySet.
{% extends 'temp_basic.html' %}
{% block content %}

{% for sts in st %}
 <a href=?id={{}}>{{}}</a><br>
{% endfor %}

{% endblock %}
<a href=./>Back</a>

Web form data inserting to MySQL table
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 All rights reserved worldwide Privacy Policy Disclaimer