我如何获得登录我的网站的用户的名字现在django

我如何获得登录我的网站的用户的名字现在django,django,django-views,django-users,Django,Django Views,Django Users,我应该在author中做什么请帮助我是这方面的新手您将需要请求.user.name(如果您的用户模型有名称字段) 更好的做法是在用户模型中添加一个真正的外键字段,而不仅仅是名称字段。请在问题中添加目标模型代码。 def show(request): if request.method == 'POST': if request.POST.get('location') and request.POST.get('member') and request.POST.get(

我应该在author中做什么请帮助我是这方面的新手您将需要
请求.user.name
(如果您的用户模型有
名称
字段)


更好的做法是在用户模型中添加一个真正的外键字段,而不仅仅是名称字段。

请在问题中添加目标模型代码。
def show(request):
    if request.method == 'POST':
        if request.POST.get('location') and request.POST.get('member') and request.POST.get('arrival') and request.POST.get('leaving'):
            dest = Destination()
            dest.location = request.POST.get('location')
            dest.member = request.POST.get('member')
            dest.arrival = request.POST.get('arrival')
            dest.leaving = request.POST.get('leaving')
            dest.author = user.name(User.objects.all())
            dest.save()
            messages.success(request, 'we will send you best option..!')
            return render(request,'travell/home.html')
    else:
        return render(request,'travell/home.html')