django template does not render complete context

I am using templates with django. I am having a problem where the Context is not being rendered. The meta_k is null. The meta_description is not.

 t = get_template('projects.html')   
 html = t.render(Context({
       'completed': completed, 
       'current':current, 
       'description': sp.description, 
       'project_title':sp.name, 
       'img':images, 
       'meta_desc': sp.meta_description, 
       'meta_k:': sp.meta_keywords
 }))

I can start the server in debug mode in eclipse and So I know sp.meta_keywords is not null. Here is where I call the code in projects.html:

{% block meta_keywords %}<br>
{% if meta_k %}<br>
&nbsp;&nbsp;&nbsp;&nbsp;{{ meta_k }}<br>
{% else %}<br>
&nbsp;&nbsp;&nbsp;&nbsp;Venkat, Rao, engineer, inventor, entrepreneur, projects, blue dart, control systems, labview<br>
{% endif %}<br>
{% endblock %}

This defaults to the else when I know meta_k should not be null. The complete code can be found here on Google Code.

What am I doing wrong?

Answers


Only suggestion for you is that most probably it is bug in your code, for us it will be difficult to debug without running your whole project.

So i suggest you experiment on command line and see if you can replicate the bug in simple steps, so that we can try to fix it. I am sure in the process you will find the problematic part

e.g. I see your template rendered correctly by my simple context

>>> from django.template import Context, Template
>>> s = """{% block meta_keywords %}<br>
... {% if meta_k %}<br>
... &nbsp;&nbsp;&nbsp;&nbsp;{{ meta_k }}<br>
... {% else %}<br>
... &nbsp;&nbsp;&nbsp;&nbsp;Venkat, Rao, engineer, inventor, entrepreneur, projects, blue dart, control systems, labview<br>
... {% endif %}<br>
... {% endblock %}"""
>>> t = Template(s)
>>> c = Context({'meta_k':['a','b','c']})
>>> t.render(c)
u'<br>\n<br>\n&nbsp;&nbsp;&nbsp;&nbsp;[&#39;a&#39;, &#39;b&#39;, &#39;c&#39;]<br>\n<br>\n'

So I was just making stupid mistake:

In the rendering file I have:

html = t.render(Context({'completed': completed, 'current':current, 'description': sp.description, 'project_title':sp.name, 'img':images, 'meta_desc': sp.meta_description, 'meta_k:': sp.meta_keywords)

this refers to "meta_k:" note the semicolon

in the template I have

{% if meta_k %}

note no semicolon

If I remove the semicolon it works. That was stupid.


Need Your Help

Stripped symbols are not hidden from strings linux tool

c linux shared-libraries stripping

I have a shared library with the symbols stripped. Using a known method/tool to get the symbol names (like nm -D, objdump, readelf, etc) I see that all the symbols are actually hidden.

Amazon S3: BucketAlreadyExists and AccessDenied errors

amazon-web-services

When I run given script for amazon web services for s3. It gives me these errors. What I am missing here however I used Access and sKey Id