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: django-users@googlegroups.com <django-users@googlegroups.com> On Behalf Of fahad rasool
Sent: Tuesday, 28 April 2020 03:08
To: django-users@googlegroups.com
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 django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACqgSmA0Cjjx8S_SqeGF1wBDQggGAXszKdApOD45-1CPBPXG0g%40mail.gmail.com.
No comments:
Post a Comment