Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check if there is something in the dictionary in django template

Tags:

python

django

I have the dictionary which i am passing to the template like this

dict['vars'] = ['a':'dd','b':'gg','c':'yy']
dict['myvars'] = ['a':'tt','b':'yy','c':'uu']

there are times

when the individual dict are empty with no key.

how can I check that like this

{%  if dict.vars empty   %}
do this
like image 885
user2294401 Avatar asked Apr 22 '13 06:04

user2294401


1 Answers

{% if not dict.vars %}
  do this
{% endif %}
like image 110
emcpow2 Avatar answered Oct 20 '22 17:10

emcpow2