Skip to main content

Add JS importmaps to your Django project without Node or any other frontend tooling.

Project description

lfp-importmap

A simple way to use Javascript importmaps in your Django projects.

What can you do with it?

Use Javascript libraries in your Django projects without having to install node and related frontend tooling like webpack, etc. No frontend build system required!

How to use it?

  1. Install from pypi
uv add lfp-importmap

or

pythom -m pip install lfp-importmap
  1. Add lfp_importmap to your INSTALLED_APPS in your settings.py
INSTALLED_APPS = [
    ...
    'lfp_importmap',
]
  1. Add any JS library using the new management command:
python manage.py importmap add htmx.org

This will create an importmap.config.json file in your project root. It will also vendor the package code and make it available in your templates.

  1. In your base.html template, add the following:
{% load lfp_importmap %}

<html>
  <head>
    ... {% javascript_importmap_tags %}
  </head>
  <body>
    ...
  </body>
</html>
  1. That's it! The module is now ready for use in your templates.

Continuing the example from above, you can now use the htmx module in your templates:

<button hx-get="{% url 'my-url-name' %}">Click me</button>

LICENSE

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lfp_importmap-0.2.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lfp_importmap-0.2.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file lfp_importmap-0.2.0.tar.gz.

File metadata

  • Download URL: lfp_importmap-0.2.0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.13

File hashes

Hashes for lfp_importmap-0.2.0.tar.gz
Algorithm Hash digest
SHA256 238e0e42baf4b77730dba89a24f2c802faf58ceb14c4f5119364bdba94efcf5c
MD5 8e80009567ea92d467643c415238b275
BLAKE2b-256 03b45abc438ec30690040fcb1b001b67090953335b8ba29c1d630be85963c64e

See more details on using hashes here.

File details

Details for the file lfp_importmap-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lfp_importmap-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 42afc2dfa2e000d96e0111e1a39858bd1e1820114b06b4d749f2f334def2f886
MD5 50774051a9c2a6494be263610c31bbe2
BLAKE2b-256 b059f573c614dadc3d2fbf85d22d7cdd777603a42ba7458df89bd18bbd75eebf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page