I am using comments app from contrib in Django 1.3.
In my website I let only authenticated users to leave a comment so I'd
like to get rid of those "name", "email" and "url" fields that come with
the standard comment form. Indeed, I already know the name and email of
current logged user, there's no need for the user to submit his/her name
and email again.
So, I'd just like a FK field to the user that left the comment. More of
that, I would like that field to be automatically populated while the
user submit the comment.
Could you give me some hints for such customization?
Thank you very much,
Fabio.
--
Fabio Natali
Ehi Vladimir, thank you for your quick reply!
I found a couple of interesting links.
http://mitchfournier.com/2010/08/12/customizing-django-comments-remove-unwanted-fields/
http://stackoverflow.com/questions/1456267/django-comments-want-to-remove-user-url-not-expand-the-model-how-to/4766543#4766543
The first deals with writing your own comment templates, so to remove
unnecessary fields (name, url, email).
The latter deals with writing your own custom comment form, no need to
hack template stuff. This looks nicer to me, I think I'll try it first.
Vladimir, is that the approach you meant?
I am still not sure this is the best solution for me. So, those of you
who are listening, if you have any further advice/hint, don't hesitate
to email me! :-)
Cheers, Fabio.
--
Fabio Natali
Hi there!
If you have an object my_object passed by your view to your template, I
think you can write:
{% load comments %}
{% get_comment_count for my_object as comment_count %}
{% get_comment_list for my_object as comment_list %}
{% get_comment_form for my_object as form %}
and then you can:
<form action="{% comment_form_target %}" method="post">
{% csrf_token %}
{{ form }}
<tr>
<td colspan="2">
<input type="submit" name="submit" value="Post">
<input type="submit" name="preview" value="Preview">
</td>
</tr>
</form>
Let me know it that's of any help. In case, write me what kind of error
you get. Also, I can pass you my source code so you can have an example.
This link worked fine for me. :-)
--
Fabio Natali FNstudio
http://fnstudio.it
fabio_natali@skype