Rohit Mandhan
Rohit Mandhan

Reputation: 89

Issue with using Django context variables in template CSS

I don't know it can be write like that or not but I am trying to set height to html item in css style. Height is being passed in context variable from Backend Django.

I am trying this:

<style>
    .fc-agendaWeek-view tr {
      height: '{{row_height|add:"0"}}'"px"
    }

</style>

{{row_height|add:"0"}} => this is context variable passed from Django Backend which is integer i-e 70 , 80.

Where I am wrong? Can we even write like that. Any help will be appreciated.

Upvotes: 0

Views: 97

Answers (1)

Niicodemus
Niicodemus

Reputation: 327

Your CSS is invalid. It often helps a lot to View Source on a page and see exactly what your template is outputting. In this case, I think you want something more like:

<style>
    .fc-agendaWeek-view tr {
      height: {{ row_height }}px;
    }
</style>

Which will output:

<style>
    .fc-agendaWeek-view tr {
      height: 70px;
    }
</style>

Upvotes: 1

Related Questions