Django 1.5:用户和附加信息 [英] Django 1.5: user and additional info

查看:110
本文介绍了Django 1.5:用户和附加信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于django auth的认证系统,但是我必须向用户添加信息。
在django 1.5中最好的做法是什么? (在1.4我正在使用与onetoone相关联的用户,但现在?)

解决方案

Django 1.5有可扩展用户模型。基本上,您可以扩展一个抽象基础用户模型,添加您的字段和任何东西,并从那里使用它。



基本型号仅具有认证的基础知识 - 密码字段和上次登录时的字段。你甚至必须创建自己的用户名字段。如果您对当前的Django用户模型(使用用户名,名字,姓氏等)感到满意,则它也以 AbstractUser 的形式存在,您可以扩展它的 AbstractBaseUser 并添加您自己的字段。


I have an authentication system based on django auth, but I have to add information to users. What is the best way to do that in django 1.5? (In 1.4 i was using a profile linked with onetoone to user, but now?)

解决方案

Django 1.5 has extendable User models. Basically, you can extend an abstract base user model, add your fields and anything and use it from there.

The base model only has the basics for authentication – the password field and a field for the time of the last login. You even have to create your own username field. If you're comfortable with something like current Django User model (with username, first name, last name, etc.), it also exists as AbstractUser and you can extend it instead of AbstractBaseUser and add your own fields.

这篇关于Django 1.5:用户和附加信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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