Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django `with` tag not recognizing keyword argument

Tags:

python

django

I have the following code in my template:

{% include "entry_table/cell.html" with data_items = data_fields class="entry_table_title" only%}

Which gives me the following error:

"with" in 'include' tag needs at least one keyword argument.

I've tried replacing data_field (which is a variable I passed into the context) with a string, just in case that was what was causing the problem, but even if I make it:

{% include "entry_table/cell.html" with data_items = "unicorn" class="entry_table_title" only%}

I still get the same error. The only thing that fixes the issue is to get rid of data_items completely, as in:

{% include "entry_table/cell.html" with class="entry_table_title" only%}

So, what's the problem?

NOTE: I just realized that data_items is also a variable that is passed into the context of the page that is calling the other template, but when i changed the name to something else, it still didn't work. So that is not the problem.

like image 939
sinθ Avatar asked Jun 15 '13 16:06

sinθ


1 Answers

Looks like Django is quite picky about whitespace in this instance. If I change...

{% include "entry_table/cell.html" with data_items = data_fields class="entry_table_title" only%}

...to...

{% include "entry_table/cell.html" with data_items=data_fields class="entry_table_title" only%}

...it works for me.

like image 198
Aya Avatar answered Oct 31 '22 20:10

Aya