A Django package to easily include Alpine.js in your Django project.
- Automatically adds Alpine.js to your Django project.
- Ensures Alpine.js is available in your
static/jsdirectory. - Falls back to a pre-packaged version of Alpine.js if CDN download fails.
- Python >= 3.10
- Django >= 4.2
-
Install the package using pip:
pip install django-alpine
-
Add
django_alpineto yourINSTALLED_APPSinsettings.py:INSTALLED_APPS = [ # Other apps 'django_alpine', ]
-
Run the
collectstaticcommand to include Alpine.js in your static files:python manage.py collectstatic
In your templates, you can load the Alpine.js script using the provided template tag.
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Django Project</title>
</head>
<body>
<!-- Include Alpine.js -->
<script src="{% static 'js/alpine.js' %}" defer></script>
<!-- Your HTML content -->
</body>
</html>-
On installation, the package:
- Copies a pre-packaged Alpine.js file to your
static/jsdirectory. - Attempts to download the latest version of Alpine.js from the official CDN.
- Copies a pre-packaged Alpine.js file to your
-
If the CDN is unavailable, the pre-packaged version will be used.
Contributions are welcome! Follow the steps below to get started:
-
Clone the repository:
git clone https://github.com/ProKelly/django-alpine.git
-
Install dependencies:
pip install -r requirements.txt
-
Make your changes and submit a pull request.
This project is licensed under the BSD License. See the LICENSE file for details.
Created and maintained by Anye Prince Kelly.
- Email: firstanye@gmail.com
- GitHub: ProKelly
- Linkedin: Anye Prince Kelly