在Django 1.6中获取用户配置文件的新方法是什么? [英] What is the new approach to get user profile in Django 1.6?

查看:173
本文介绍了在Django 1.6中获取用户配置文件的新方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Django很新我试图通过 request.user.get_profile()的帮助获取用户个人资料,但是有一个警告:使用 AUTH_PROFILE_MODULE 已被弃用。



我的settings.py中有一行: AUTH_PROFILE_MODULE =log_viewer.Configs其中配置是一个带有字段以保留用户配置文件设置的模型。



这样做的新方法是什么?

解决方案

首先,为用户创建一个个人资料:

  User.profile = property(lambda u:Configs.objects.get_or_create(user = u)[0])

并使用它来获取配置文件:

  request.user.profile 

更多详细信息: https: //code.djangoproject.com/ticket/15937


I'm quite new to Django. I'm trying to get user profile with the help of request.user.get_profile() but there is a warning that the use of AUTH_PROFILE_MODULE has been deprecated.

I have a line in my settings.py: AUTH_PROFILE_MODULE = "log_viewer.Configs" where Configs is a model with fields to keep user profile settings.

What is the new approach of doing this?

解决方案

At first,I create a 'profile' for User:

User.profile = property(lambda u: Configs.objects.get_or_create(user=u)[0])

and use this to get the profile:

request.user.profile

more detail here: https://code.djangoproject.com/ticket/15937

这篇关于在Django 1.6中获取用户配置文件的新方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆