Hi group,
I would like to ask you for a feedback about this small piece of code
which I make for testing this behaviour. Put the function
test_ifequal() as a view into your app, mount it as a URL and see the
page and then click the button.

The problem I see in this code is - when I access this page via GET,
then ifequal works correctly. When I access this page via POST, the
ifequal behaves strange. Can anybody explain it? I got the same
behaviour with 0.96 and trunk version.

When I use {% debug %} I can see that both results (Context for GET or
POST) are the same.

Thanks for any clues,
Michal

# -*- coding: UTF-8 -*-

from django.db import models
from django.http import HttpResponse
from django.template import Template, Context

CHOICES = (
        (0, 'Zero'),
        (100, 'One hundred.'),
        (200, 'Two hundred.'),
)
class TestItem(models.Model):
        status = models.IntegerField(default=0, choices=CHOICES)

def test_ifequal(request):

        template_content = '''
                {% for choice in choices %}

                        {% ifequal choice.0 item.status %}
                                According to ifequal these values equal:
                        {% else %}
                                According to ifequal these values don't equal:
                        {% endifequal %}

                        {{ choice.0 }}, {{ item.status }}
                        <br />

                {% endfor %}

                <form action="./" method="post">
                <input type="text" name="status" value="100" />
                <input type="submit" />
                </form>

                {% debug %}
        '''

        item = TestItem()

        status = request.POST.get('status', 100)
        item.status = status

        t = Template(template_content)
        c = Context({'item': item, 'choices': CHOICES})
        html = t.render(c)
        return HttpResponse(html)

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to