Hello Fahad 

If you didn’t extend user model your view.py it will be like

@login_required

def userdetails(request):

    user_details = User.objects.get(username=request.user)

    context {

        "user_details": user_details,

    }

    return render(request, 'accounts/profile.html', context)

 

Then on your app.urls

from .views import user_details

 

app_name = "your_app_name"

 

urlpatterns = [

     path('details/', user_details, name="profile")

]

 

 

On profile.html

{% block content %}

 

    <div class="container">

        <p>First Name: {{user_details.first_name}}</p>

        <p>Last Name: {{user_details.last_name}}</p>

        <p>Email:{{user_details.email}} </p>

        ...

    </div>

{% endblock content %}

 

From: [email protected] <[email protected]> On Behalf 
Of fahad rasool
Sent: Tuesday, 28 April 2020 03:08
To: [email protected]
Subject: 

 

How to retrieve data from database and display on web page ,example i want to 
display the details of the user on  a web page which he has entered in a form 
which is stored in database.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected] 
<mailto:[email protected]> .
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACqgSmA0Cjjx8S_SqeGF1wBDQggGAXszKdApOD45-1CPBPXG0g%40mail.gmail.com
 
<https://groups.google.com/d/msgid/django-users/CACqgSmA0Cjjx8S_SqeGF1wBDQggGAXszKdApOD45-1CPBPXG0g%40mail.gmail.com?utm_medium=email&utm_source=footer>
 .

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/010101d61d0d%2407dd6ae0%24179840a0%24%40gmail.com.

Reply via email to