Django多个用户配置文件/子文件 [英] Django multiple User profiles/subprofiles
问题描述
我正在尝试创建具有内部/外部用户特定配置文件的内部网/外部网,具有通用的通用配置文件。我已经看了这个网站上的几个答案,但没有一个专门解决我正在寻找什么。以下是我迄今为止的(剥离)文件。
创建配置文件模型的最佳方法是什么,每个用户类型都有子文件?如果可能,我试图不要求自定义身份验证后端。
https://gist.github.com/1196077
您需要组合存储有关用户和<一个href =https://docs.djangoproject.com/en/1.3/topics/db/models/#model-inheritance =nofollow>模型继承。
基本上,您将需要通用的用户
模型,我们都知道,爱或恨,然后您需要一个通用配置文件模型,这是您的 AUTH_PROFILE_MODULE
设置。
该配置文件模型将是顶级模型,内部和外部用户的模型子类。您可能不想在这种情况下使用抽象模型,因为您需要一个通用配置文件表才能从 User.get_profile()$ c $加载用户配置文件c>。
所以...我想你想要改变的主要事情是让你的Associate,External等模型继承自你的Profile模型。 p>
I am trying to create an intranet/extranet with internal/external user-specific profiles, with a common generic profile. I've looked at several answers on this site, but none specifically address what I'm looking to do. Below are the (stripped down) files I have so far.
What's the best way to create a profile model, with subprofiles for each user type? I'm trying not to require a custom authentication backend if at all possible.
https://gist.github.com/1196077
You need a combination of storing additional information about users and model inheritance.
Basically, you'll need the generic User
models we all know and either love or hate, and then you need a generic profile model that is your AUTH_PROFILE_MODULE
setting.
That profile model will be a top-level model, with model subclasses for internal and extrernal users. You probably don't want an abstract model in this case since you'll need a common profile table to load user profiles from with User.get_profile()
.
So...I think the major thing you want to change is to make your Associate, External, etc. models inherit from your Profile model.
这篇关于Django多个用户配置文件/子文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!