1

I'm trying to make a django reusable app that will basically contain bunch of template tags.

How and what are the best practices for allowing app-specific js to be easily loaded using the app.

Is there a way a user can just put {% load app_name %} and the app will load its js in the html or does the user expecility need to write a <script src='..'></script> tag before using the app's template tags.

1 Answer 1

1

Just put <script ...> in a template in your reusable app, and include that template in any app you want:

{% include "reusable_app/js_header.html" %}

The reusable app needs to be listed in INSTALLED_APPS to find the templates.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.