问题
I'm trying to get the model name for different objects:
This kinda works:
last_profile = Profile.object.last()
profile.__class__._meta.verbose_name // 'profile'
But not for a compounded model name such ProfileLogin
:
last_profile_login = ProfileLogin.objects.last()
last_profile_login.__class__._meta.verbose_name // 'profile login'
I would like the last example to be profile_login
.
The reason, I'm doing this is to create a dynamic query using filter().
来源:https://stackoverflow.com/questions/60326533/get-relationship-model-name-of-object-django