0

So I have a base.html template and a review_result.html template that extends the base.html template. The base.html template has a script tag with lots of function. I am going to move a function called format from a script tag in the review_result.html to the base.html file. How do I then call the format function in review_result.html from base.html?

TritonKid
  • 1
  • 1
  • What do you mean when you say your `base.html` _has_ a script tag? Generally speaking, _templates_ do not contain function code or tags. Available tags are either builtin or controlled by your site configuration or loaded in using `{% load %}` -- in any case, they are not _inside_ your templates, exactly. See [custom template tags](https://docs.djangoproject.com/en/3.2/howto/custom-template-tags/). Also, does this answer your question: [Is it possible to load a custom template tag in base and use it in extented templates](https://stackoverflow.com/q/20560222/5747944) ? – sytech Nov 30 '21 at 02:30
  • Hey there, welcomne to SO. It's a good question but could you edit your post and add any code that you have tried? It will definitely help any answers. – Cutey from Cute Code Dec 04 '21 at 16:52

1 Answers1

0

Django templates just become static html (script tags included). If you extend from another template and it includes your JavaScript, then you should be able to call the function as though your format function were in your review_result.html template.