我正在为每个用户创建一个页面,如何在我的 django 用户模型中查找用户名
views.py
def user_page(request,user):
user = User.objects.filter(user =user.username)
return render_to_response('user_page.html',"user":user,context_instance=RequestContext(request))
我正在为每个用户创建一个页面,如何在我的 django 用户模型中查找用户名
views.py
def user_page(request,user):
user = User.objects.filter(user =user.username)
return render_to_response('user_page.html',"user":user,context_instance=RequestContext(request))
def user_page(request,username):
user = User.objects.filter(username=username)
return render_to_response('user_page.html',{"user":user},context_instance=RequestContext(request))
from django.contrib.auth.models import User
from django.shortcuts import get_object_or_404
def user_page(request, username):
user = get_object_or_404(User, username=username)
return render_to_response('user_page.html',{"user":user},context_instance=RequestContext(request))