Closed jimkring closed 4 years ago
The COMMENTS_XTD_API_USER_REPR
setting is used only related with comment's like/dislike flags.
But I think your guess about get_full_name
is in the right track. When you do {{ item.comment.name }}
you are accessing the getter _get_name
from django-comments, see the code between lines 91 and 130. It's not related with django-comments-xtd. But I think that code will give you the clue.
OK, thanks for that info @danirus
@danirus I see what you're saying about that, now that I've looked at some of the code. I guess maybe I need to read through the docs/code for django-comments more to better understand how this part works. Thanks again!
I'm using the setting to sets the function to use when getting the user's display name.
COMMENTS_XTD_API_USER_REPR = lambda u: u.get_full_name()
I noticed an oddity:
{{ item.comment.name }}
will render a user's email address (since I'm usingAbstractEmailUser
class) regardless of what I set the value ofCOMMENTS_XTD_API_USER_REPR
. However,{{ item.comment.name }}
will correctly render as my user's full name if (and only if) I define aget_full_name()
function in my user class, and it seems to do this, regardless of what I have setCOMMENTS_XTD_API_USER_REPR
as.My guess is that the rendering of {{ item.comment.name }} is using some hard-coded function like
get_full_name()
instead of using the one defined by theCOMMENTS_XTD_API_USER_REPR
setting.Steps to reproduce:
1) Set
COMMENTS_XTD_API_USER_REPR = lambda u: u.get_full_name2()
(and implement theget_full_name2()
method in the user class.2) Note that
{{ item.comment.name }}
renders as the user's email address.3) Now, implement an additional
get_full_name()
in the user class (without changing theCOMMENTS_XTD_API_USER_REPR
setting -- leave that pointing atget_full_name2()
) and notice that{{ item.comment.name }}
renders as the user's full name.4) As an added bonus, remove the
COMMENTS_XTD_API_USER_REPR
setting and note that{{ item.comment.name }}
still renders as the user's full name, since we have aget_full_name()
method in the user class.This is what leads me to believe that the rendering of
{{ item.comment.name }}
is ignoring theCOMMENTS_XTD_API_USER_REPR
setting.