Getting an Error: Reverse for 'show_user_profile_view_url' with arguments '('',)' not found. 1 pattern(s) tried: ['members/(?P<pk>[0-9]+)/user_profile\\Z']

I’m getting an this error when placing a link on the navbar that directs logged in users to their profile page and it does not work.

I tried all the solutions here and non worked.

Any thoughts?

    <a href="{% url 'show_user_profile_view_url' post.author.profile.pk %}">profile page</a>



class ShowProfilePageView(generic.DetailView):
	model = Profile 
	template_name = 'registration/user_profile.html'

def get_context_data(self, *args,**kwargs):
	users = Profile.objects.all()
	context = super(ShowProfilePageView, self).get_context_data(*args,**kwargs)
	page_user = get_object_or_404(Profile,id=self.kwargs['pk'])
	context['users']=users
	context['page_user']=page_user
	return context

What does your urls.py entry for this look like?

There are a couple things here - first is the formatting. Is your get_context_data supposed to be part of your ShowProfilePageView class? It’s showing here like it’s not.

Also, in your template, you reference post.author.profile.pk. Where is that defined in your view?

Yes it does.

class ShowProfilePageView(generic.DetailView):
	model = Profile 
	template_name = 'registration/user_profile.html'

	def get_context_data(self, *args,**kwargs):
		users = Profile.objects.all()
		context = super(ShowProfilePageView, self).get_context_data(*args,**kwargs)
		page_user = get_object_or_404(Profile,id=self.kwargs['pk'])
		context['users']=users
		context['page_user']=page_user
		return context

I’m trying to pass the user profile details through the users = Profile.objects.all() and context[‘users’]=users

Is this the right way to do it?

thank you

Let’s look at this from a different direction.

The parameter you’re specifying in this url tag is:
post.author.profile.pk

What does this expression (post.author.profile.pk) mean? (What is it referring to?)

If you’re not sure, start with reviewing the documentation at Templates | Django documentation | Django.