我是 Django 的新手。我使用内置User
模型编写了一个登录脚本。
def login_user(request):
state = "Please login below..."
username = password = ''
if request.POST:
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
state = "You're successfully logged in!"
return render_to_response('home.html',{'username': username})
else:
state = "Your account is not active, please contact the site admin."
else:
state = "Your username and/or password were incorrect."
return render_to_response('index.html',{'state':state})
这将打开一个新页面home
,我在其中显示{{username}}
. 但是,我如何才能从该特定位置检索其他值,例如 ,id
等,并将它们显示在我的页面上。我试过使用,但它似乎不起作用。email
fullname
username
database
home
User.objects.all()