last day (15 days later) » 

11:59 AM
1
A: How To Make User Profile In Django?

sandeepCreate a URL in urls.py like this: path('profile/<username>', views.user_profile, name='user_profile'), views.py (If you are using User model to save user data.) def user_profile(request, username): user = User.objects.get(username=username) context = { "user": user } ...

 
i get this error Reverse for 'user_profile' with no arguments not found. 1 pattern(s) tried: ['profile/(?P<username>[^/]+)$']
 
did you pass "username" in url?
 
Yes I pass in url
 
if username is "Hamza", pass profile/Hamza.
 
Okay Thanks That Work!
but when i do that the use is login
Without password
Now I Get This Problem When i type for example http://127.0.0.1:8000/profile/test/ the user is login without password and username
 
11:59 AM
sorry, question is not clear.
 
I Will Ask New Question So You Can Understand Better
1 Last Thing If Insert this line <li class="nav-item"> <a class="nav-link navaour" href="{% url 'user_profile' %}"><i class="fa fa-check-square-o"></i>&nbsp; Sign up Free</a> </li> in my base.html i get this error Reverse for 'user_profile' with no arguments not found. 1 pattern(s) tried: ['profile/(?P<username>[^/]+)$']
 
answer updated.
 
NOW i get this error Could not parse the remainder: '<username>' from '<username>'
 
can you show your code?
 
Code <a class="nav-link navaour" href="{% url 'user_profile' username=<username> %}"><i class="fa fa-user"></i>&nbsp; Profile</a>
Sandeep Here is error screenshot
 
12:01 PM
you have to replace <username> with username. if username is Hamza, link is {% url 'user_profile' username=Hamza %}. If you are passing user instance, use username=user.username
 

last day (15 days later) »