[英]Storing new field to Django Admin “user” section from registration form
我設法在“注冊”表單中添加了一個附加字段,“您在哪里得知我們的?”。
但是我不確定要編輯哪些文件以存儲來自該字段的數據以及用戶信息。
即當登錄到管理員部分,並轉到“用戶”並查看用戶信息,我想在那里看到此字段。
最簡單的方法是在有關用戶的UserProfile
模型中存儲其他數據 ,例如
from django.contrib.auth.models import User
class UserProfile(models.Model):
# This field is required.
user = models.OneToOneField(User)
# Other fields here
where_heard_about_us = models.TextField()
然后,您可以在Django Admin中將該對象注冊為嵌入式對象。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.