Django 1.2 - Pb with a form in a template (WSGIRequest)

Posted by Tom on Stack Overflow See other posts from Stack Overflow or by Tom
Published on 2010-03-16T08:58:25Z Indexed on 2010/03/16 9:16 UTC
Read the original article Hit count: 206

Filed under:

Hi, I'm trying to display a form on a template, but I get a fantastic error :

Caught AttributeError while rendering: 'WSGIRequest' object has no attribute 'get'

The error is in this line : {% for field in form.visible_fields %}

My view :

def view_discussion(request, discussion_id):
 discussion = get_object_or_404(Discussion, id=discussion_id)
 form = BaseMessageForm(request)

 return render(request,'ulule/discussions/view_discussion.html', {
  'discussion':discussion,
  'form':form,
 })

My form :

class BaseMessageForm(forms.Form):
 message_content = forms.CharField(widget=forms.HiddenInput())

My template :

<form action="" method="post">
{% csrf_token %}
    {% for field in form.visible_fields %}
        <div class="fieldWrapper">
            {% if forloop.first %}
                {% for hidden in form.hidden_fields %}
                {{ hidden }}
                {% endfor %}
            {% endif %}

            {{ field.errors }}
            {{ field.label_tag }}: {{ field }}
        </div>
    {% endfor %}
    <p><input type="submit" value="Send message" /></p>
</form>

Thanks a lot for your help !

© Stack Overflow or respective owner

Related posts about django