1

I am trying to add a value in page footer from value of context variable in django template.

I have added following code in internal css of django template.

@page{
@bottom-right {
   content: "Invoice No :- " {{ obj.property }} "Page No." counter(page) "/" counter(pages)
 }
}

Above code does not work after using {{ obj.property }} Since i think django template does not allow to change internal css with context variables.

I also referred this question.

Is there any way to do this in css or in combination with jquery(or js)?

Community
  • 1
  • 1
devlin31
  • 81
  • 10
  • Can you give an example what is rendered (show source), and what you expect to be rendered? Edit: I use the Django template system a lot for dynamic values for inline javascript and inline css – het.oosten Aug 18 '16 at 12:28
  • I am just showing a template. the code i mentioned in question is showing page count @ bottom-right of page when i convert the template to pdf. It works perfectly except when trying to add some dynamic value from context variable passed to django template :( – devlin31 Aug 18 '16 at 12:48
  • @het.oosten specified css code is placed in internal css(and not inline). have you worked on internal css (or css using javascript) from context passed to django template? – devlin31 Aug 23 '16 at 07:15

1 Answers1

1

I found the answer. My syntax was not proper while showing data.

I just added '' around {{ object.property }} and it is working fine.

So my new code is simply.

        @page{
        @bottom-right {
           content: "Invoice No :- " '{{ obj.property }}' " Page No." counter(page) "/" counter(pages)
         }
    }
devlin31
  • 81
  • 10