在要将用户id作为参数传递到url的配置文件路径中:
path('profile/',views.profile\u detail,name='profile')
但是您将用户模型而不是模板中的id传递给它:
<a class="nav-link navaour" href="{% url 'profile' pk=user.pk %}"><i class="fa fa-user"></i> Profile</a>
应该是这样的:
<a class="nav-link navaour" href="{% url 'profile' pk=user.id %}"><i class="fa fa-user"></i> Profile</a>
要将pk string转换为int进行查询,您需要fix to view:
def profile_detail(request,pk):
model = get_object_or_404(User, pk=int(pk))
template_name = 'profile_detail_view.html'