擅长:python、mysql、java
<p>这并不完全是对您的问题的回答,但是,根据<a href="https://docs.djangoproject.com/en/1.3/ref/contrib/admin/">Django Admin documentation</a>,您可以在用户“表”中显示来自UserProfile的信息。你可以让它搜索。</p>
<p>这看起来像这样(修改C.Alan Zoppa的答案):</p>
<pre><code>class UserProfileAdmin(UserAdmin):
inlines = [ UserProfileInline, ]
def company(self, obj):
try:
return obj.get_profile().company
except UserProfile.DoesNotExist:
return ''
list_display = UserAdmin.list_display + ('company',)
search_fields = UserAdmin.search_fields + ('userprofile__company',)
</code></pre>
<p>如果您的profile类不再被称为<code>UserProfile</code>,那么您在搜索时可能会遇到问题。</p>