- Django Design Patterns and Best Practices
- Arun Ravindran
- 93字
- 2021-06-25 21:32:08
Admin
Now, a user's details will be in two different places within the admin: the authentication details in the usual user admin page, and the same user's additional profile details in a separate profile admin page. This gets very cumbersome.
For convenience, the profile admin can be made inline to the default user admin by defining a custom UserAdmin in profiles/admin.py as follows:
from django.contrib import admin from django.contrib.auth.admin import UserAdmin from .models import Profile from django.contrib.auth.models import User class UserProfileInline(admin.StackedInline): model = Profile class NewUserAdmin(UserAdmin): inlines = [UserProfileInline] admin.site.unregister(User) admin.site.register(User, NewUserAdmin)
推薦閱讀
- Mastering JavaScript Functional Programming
- C和C++安全編碼(原書第2版)
- aelf區塊鏈應用架構指南
- 軟件架構:Python語言實現
- Drupal 8 Configuration Management
- VMware虛擬化技術
- Integrating Facebook iOS SDK with Your Application
- Scratch·愛編程的藝術家
- C語言程序設計與應用(第2版)
- Elasticsearch Essentials
- Python大規模機器學習
- 算法秘籍
- Python第三方庫開發應用實戰
- C# 7.0本質論
- SQL Server 2008實用教程(第3版)