views:

18

answers:

1

I'm using the standard Django comments app in my project. If the User is logged in then the comment form still shows fields for user_name and user_email. If anything is entered into those, the data is saved to the database with the comment, along with the user_id of the logged-in User.

When the comment is displayed, the name of the logged-in User is shown, rather than the user_name entered into the comment form.

I would have expected the user_name and user_email fields to not be shown on the form if the User is logged in, as they're pointless in this situation. Is it supposed to behave like that way and I've done something wrong? If this is, bizarrely, standard behaviour, what's the very simplest way to hide these fields (or use the logged-in User's name/email) when the User is logged in? Thanks.

A: 

Keep in mind that generic Django apps are designed to be, well.. generic. They don't necessarily handle all the special cases.

If you want to change this form, you should write your own template. In the template, you can use !user.is_authenticated to add fields to the form (make sure you are using RequestContext).

André Caron
Thanks for the suggestion André. I realise the apps are supposed to be generic but this doesn't seem like a special case - it seems broken. I'd have thought the default behaviour should be sensible, but this seems confusing for any users who are logged in when they post a comment.
Phil Gyford