AbstractUser Django full example

前端 未结 2 1031
盖世英雄少女心
盖世英雄少女心 2021-02-02 00:48

I am new to Django and I have been trying this for weeks, but could not find a way to solve this problem.

I want to store additional information like user mobile number,

2条回答
  •  逝去的感伤
    2021-02-02 01:27

    Inlines forms assume that you have a Generic ForeignKey on your model, in this case, the UserProfileAdmin expect a Generic ForeignKey of the UserProfile, that does not exists. Try to do a regular Model Admin, like:

    class UserProfileAdmin(admin.ModelAdmin):
        can_delete = False
        verbose_name_plural = 'userprofile'
    
    admin.site.register(UserProfile, UserProfileAdmin)
    

提交回复
热议问题