On Sep 1, 6:22 pm, oversize <[EMAIL PROTECTED]> wrote: > Hello, > i just had the following problem and am not sure whether this is the > way its wants to be: > > I used {% get_comment_form for foo as form %} to build my own custom > form. The Form is very simple because only logged in user can access > the page where one would be able to comment. Which is why i did not > want to have an extra field for username in the comment form; Here is > my form: > > <form class="CommentForm" action="{% comment_form_target %}" > method="post"> > {{ form.comment.label_tag }} {{ form.comment }} > {{ form.object_pk }} > {{ form.content_type }} > {{ form.timestamp }} > {{ form.security_hash }} > </form> > > But when i committed the form i always got the error that i have to > pass in a username. But the user _is_ authenticated.
If the user is logged in and you've RequestContexts enabled, then you can easily pass the username like request.user.username > Looking in post_comment shows that if the form does not provide a name > field, the request.user.get_full_name() is retrieved. But as those > fields (Firstname and Lastname) are not required by the user model my > user did not had them filled in. And as the data["name"] variable then > has an empty string, still. the form fails. > Providing Firstname and Lastname for the User solves the Problem. This is not a specific case for comments alone but to any app that uses the User model. > I guess this should retrieve the username of the currently logged in > user instead of get_full_name()? For any general web-application, every user is expected to enter his details like first name and last name so it's not a usual case to have both of them empty. But your point has been noted, will have a discussion with the core devs before taking this further. -- Cheers Theju --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---