0

我想向我的 django 项目添加用户设置自己的设置的能力,当用户登录时 Django 应该记住这一点。我还希望我的项目有一些对每个用户都相同的全局设置。例如,在用户登录系统之前,将为每个用户设置一个语言。(全局设置)但在用户通过身份验证后,django 将切换到他喜欢的语言。最好的方法是什么?我的想法是全局设置(语言、区域设置等)的设置文件和用户特定偏好的设置应用程序。特定于用户的偏好可能与非常简单但特定的人员有关,例如事物外观的颜色等。创建设置应用程序是正确的方法吗?没有代码只需要在实现之前首先指向正确的方向

4

2 回答 2

1

IMHO if the settings depends on user preferences I think a database is the way to store them, not files. Settings files are inherent to project's settings and database storage (normally) is the one who should persist dynamic user preferences.

于 2013-11-05T14:09:16.103 回答
1

Edit: I thought first you want to generate the Django settings based on the admins, I didn't read your question completely.

Anyway for user specific settings and preferences, definitely use a database. None use files for such tasks, you can query a database and create all your fields easily using Django's ORM.

于 2013-11-05T14:10:48.203 回答