guettli
guettli

Reputation: 27855

Dependency from django app to jquery plugin

I write a reusable django app. This app uses the are-you-sure jquery library.

Goal

Installing my app with all dependencies should be easy.

Use Case

If a developer wants to use my app, then the following line should install the whole app (including the are-you-sure plugin):

pip install myreusableapp

Question

What is the common solution to pull in dependency to open source JS code?

Not part of the question

Upvotes: 3

Views: 544

Answers (2)

Antonis Christofides
Antonis Christofides

Reputation: 6939

As Dekel said, the easiest solution is to use a third-party CDN.

If, however, you don't want to rely on a third-party CDN, the common solution is to include a copy of the JS library in your app's repository. For example, django itself does this with jquery. You will need to use the package_data argument of setup() to include the JS library in your distributable.

Upvotes: 2

Dekel
Dekel

Reputation: 62566

Since you are talking about open-source javascript library you can rely on CDNs (same way you rely on jQuery in your code).

In this specific example - you can use cdnjs for that:
https://cdnjs.com/libraries/jquery.AreYouSure

Just make sure the template you are using includes the relevant script file:

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.AreYouSure/1.9.0/jquery.are-you-sure.min.js"></script>

Upvotes: 3

Related Questions