- Django Design Patterns and Best Practices
- Arun Ravindran
- 138字
- 2021-06-25 21:32:08
Solution details
The officially recommended solution is to create a user profile model. It should have a one-to-one relation with your user model. All the additional user information is stored in this model:
class Profile(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE,
primary_key=True)
It is recommended that you set the primary_key explicitly to True to prevent concurrency issues in some database backends such as PostgreSQL. The rest of the model can contain any other user details, such as birth-date, favorite color, and so on.
While designing the profile model, it is recommended that all the profile detail fields must be nullable or contain default values. Intuitively, we can understand that a user cannot fill out all their profile details while signing up. Additionally, we will ensure that the signal handler also doesn't pass any initial parameters while creating the profile instance.
- Learning Neo4j
- Python編程自學手冊
- LabVIEW程序設計基礎與應用
- Java Web及其框架技術
- 跟老齊學Python:輕松入門
- The Computer Vision Workshop
- 第一行代碼 C語言(視頻講解版)
- Java程序員面試筆試寶典(第2版)
- Scala for Machine Learning(Second Edition)
- Statistical Application Development with R and Python(Second Edition)
- Unity&VR游戲美術設計實戰(zhàn)
- 硬件產品設計與開發(fā):從原型到交付
- Android Game Programming by Example
- CodeIgniter Web Application Blueprints
- 貫通Tomcat開發(fā)