Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AssertionError - no exception supplied - django

I am really confused not knowing what it wants from me.

this is my simple function

def confirm_abo(request):
  try:
      abo = Abonnement.objects.get(id=int(request.GET.get('abocid')))
      abo.status = 1
      abo.save()
      link = "http://127.0.0.1:8000/delete_link/?abocid=" + str(abo.id)
      subject = "test subject"
      message = "test message" + link
      send_mail(subject, message, '[email protected]', [abo.email], fail_silently=False)
      return render(request,'abo_confirm.html',{'abo':abo,'abo_success':'yes'})
  except: 
      return render(request,'abo_confirm.html',{'abo_success':''})#<-- problem

and i am getting in this last line

AssertionError at /confirm_abo/ No exception supplied

Error.

i am in django1.4 and python 2.7. it was working till now without any issues..

what am i doing wrong?

like image 766
doniyor Avatar asked Jan 26 '14 12:01

doniyor


1 Answers

Check the template abc_confirm.html whether it contains invalid tag usage like following:

{% if x == '0' %}
...
{% else if x == '1' %}   {# used `else if` instead of `elif` %}
...
{% endif %}

could cause AssertionError ..:

>>> from django.template import Template, Context
>>>
>>> t = Template('''
... {% if x == '0' %}
...              ..
... {% else if x == '1' %}
...              ..
... {% endif %}
... ''')
Traceback (most recent call last):
  File "<console>", line 7, in <module>
  File "/home/falsetru/.virtualenvs/django14/local/lib/python2.7/site-packages/django/template/base.py", line 125, in __init__
    self.nodelist = compile_string(template_string, origin)
  File "/home/falsetru/.virtualenvs/django14/local/lib/python2.7/site-packages/django/template/base.py", line 153, in compile_string
    return parser.parse()
  File "/home/falsetru/.virtualenvs/django14/local/lib/python2.7/site-packages/django/template/base.py", line 267, in parse
    compiled_result = compile_func(self, token)
  File "/home/falsetru/.virtualenvs/django14/local/lib/python2.7/site-packages/django/template/defaulttags.py", line 919, in do_if
    assert token.contents == 'endif'
AssertionError
like image 85
falsetru Avatar answered Oct 25 '22 07:10

falsetru