ELSE don't work

28 views
Skip to first unread message

Emerson Luiz

unread,
May 20, 2015, 9:37:12 AM5/20/15
to django...@googlegroups.com
Hi,

I have the following logic:

{% if rt.controle == 1 and rt.Exten|length > 7 %}
WORK's 
{% elif rt.controle == 1 %}
WORK's 
{% elif rt.controle == 0  and rt.Exten|length > 7 %}
WORK's 
{% elif rt.controle == 0 %}
WORK's 
{% else %}
DON'T WORK's

{% endif %}


My problem here is the ELSE statement don't work's. Someone can show me where i make's error ?

Thanks.

Shai Efrati

unread,
May 20, 2015, 9:45:25 AM5/20/15
to django...@googlegroups.com
What does rt.controle hold?
Do you pass any values that are not 0 or 1?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/45c32aa1-22cb-4c62-8ce2-cb8442201f70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Emerson Luiz

unread,
May 20, 2015, 9:52:45 AM5/20/15
to django...@googlegroups.com
Shai Efrati,

Thanks for answer...

rt.controle pass always 0 or 1
I not pass any value.. only 0 or 1

Thanks

Shai Efrati

unread,
May 20, 2015, 9:55:35 AM5/20/15
to django...@googlegroups.com
So, when do you expect else? It seems that you don't pass such values.

Message has been deleted

Emerson Luiz

unread,
May 20, 2015, 10:02:52 AM5/20/15
to django...@googlegroups.com
When i don't have 0 or 1 i need show some thing...

Let me explain the situation...

0 = Show when calls is RING
1 = Show when the calls is ANSWER

When i don't have calls, i need show some thing . I have an python script making insert in real time all calls statement in mysql


You can see the code here: https://gist.github.com/eluizbr/dd8dd597c83175cd5866

Thanks

Tom Evans

unread,
May 20, 2015, 10:14:36 AM5/20/15
to django...@googlegroups.com
On Wed, May 20, 2015 at 3:00 PM, Emerson Luiz <elu...@gmail.com> wrote:
> When i don't have 0 or 1 i need show some thing...
>
> Let me explain the situation...
>
> 0 = Show when calls is RING
> 1 = Show when the calls is ANSWER
>
> When i don't have calls, i need show some thing . I have an python script
> making insert in real time all calls statement in mysql
>
> Thanks
>

If you only pass 0 or 1 as the value, then it will never fall in to
your else block since it will match one of the earlier if/elif blocks.

What value are you passing that isn't 1 or 0, so that it will not
match one of the first four blocks?

Cheers

Tom

Shai Efrati

unread,
May 20, 2015, 10:33:22 AM5/20/15
to django...@googlegroups.com
In the gist you show only the template. Can you send a gist with the code that creates 
rt.controle?

Emerson Luiz

unread,
May 20, 2015, 10:47:55 AM5/20/15
to django...@googlegroups.com
Shai Efrati,

rt.controle is create by in view: 

exten = rt_calls.objects.all()

Shai Efrati

unread,
May 20, 2015, 11:02:17 AM5/20/15
to django...@googlegroups.com
What do you have in models.py for rt_calls?
Did you try passing values that are not 0 or 1?


Emerson Luiz

unread,
May 20, 2015, 12:19:23 PM5/20/15
to django...@googlegroups.com
Shai Efrati,

this:


class rt_calls(models.Model):
    Channel = models.CharField(blank=True, null=True, max_length=100)
    ChannelState = models.IntegerField()
    ChannelStateDesc = models.CharField(blank=True, null=True, max_length=10)
    CallerIDNum = models.IntegerField(blank=True, null=True, max_length=40)
    CallerIDName = models.CharField(max_length=100)
    ConnectedLineNum = models.CharField(blank=True, null=True, max_length=100)
    ConnectedLineName = models.CharField(blank=True, null=True, max_length=100)
    AccountCode = models.CharField(blank=True, null=True, max_length=100)
    Context = models.CharField(blank=True, null=True, max_length=100)
    Exten = models.CharField(blank=True, null=True, max_length=100)
    Priority = models.IntegerField(blank=True, null=True, max_length=10)
    Uniqueid = models.CharField(max_length=100)
    Application = models.CharField(blank=True, null=True, max_length=100)
    Duration = models.TimeField()
    BridgeId = models.CharField(blank=True, null=True, max_length=200)
    controle = models.IntegerField(max_length=1, default=0, blank=True, null=True)
    
    def __unicode__(self):
       return unicode(self.ChannelState)

Emerson Luiz

unread,
May 20, 2015, 1:31:43 PM5/20/15
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages