在Django模板中显示{{ user }}时,默认行为是显示用户名,即user.username。我正在更改它以显示用户的首字母,它们存储在一个单独的(OneToOneField) UserProfile模型中。因此,我想要做的是,每当从数据库调用一个select_related('userprofile')模型时,就自动使用User,因为在
我正在阅读Django文档(https://docs.djangoproject.com/en/3.0/ref/contrib/contenttypes/#module-django.contrib.contenttypes我不理解内容类型应用程序,Django文档描述如下 Django includes a contenttypes application that can track all of the modelsinstalled i