Template rendering fails when both form data and a tuple are passed to
render_to_response.

Python: 2.6.2; Django: 1.1; Environment: Windows + built-in dev server

I use the standard django.contrib.auth.models.User and .Group models.

View:

class FuksiForm(forms.Form):
        ryhmat = forms.ModelChoiceField(queryset=Group.objects.none(),
empty_label = "Ei saapunut")

        def __init__ (self, qset):
                super(FuksiForm, self).__init__(qset)
                self.fields["ryhmat"].queryset = qset

def fuksit(request, ohjelma_id):
        if request.method == 'POST': # If the form has been submitted...
                form = FuksiForm(request.POST) # A form bound to the POST data
                if form.is_valid(): # All validation rules pass
                        msg = 'meh'
                        return HttpResponse(msg)

        else:
                users = User.objects.filter(ryhma__nimi__startswith=ohjelma_id)

                groups = Group.objects.filter(name__startswith=ohjelma_id)

                form = FuksiForm(qset = groups)
                d = {'form': form, 'pf': users}


Template:

<table>
{% for u in pf %}
        <tr>
                <td>{{ u.first_name }} {{ u.last_name }}</td>
                <td>{{ u.username }}</td>
                <td>{{ form.ryhmat.errors }} <label 
for="id_ryhmat">Ryhma</label>
{{ form.ryhmat }}</td>
        </tr>
{% endfor %}
</table>

This produces: http://users.tkk.fi/jjpelto3/exception.html

When either form or pf are removed from the dictionary, the program
works fine. However, everything seems to be fine until
render_to_response when I do debugging in the shell.

I suspect a bug in the rendering handler, since people on #django were
unable to help either. There are no documented similar cases.

I am utterly perplexed. Please help. :)

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to