Skip to content

ProKelly/django-alpine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

django-alpine

A Django package to easily include Alpine.js in your Django project.

Features

  • Automatically adds Alpine.js to your Django project.
  • Ensures Alpine.js is available in your static/js directory.
  • Falls back to a pre-packaged version of Alpine.js if CDN download fails.

Installation

Requirements

  • Python >= 3.10
  • Django >= 4.2

Installation Steps

  1. Install the package using pip:

    pip install django-alpine
  2. Add django_alpine to your INSTALLED_APPS in settings.py:

    INSTALLED_APPS = [
        # Other apps
        'django_alpine',
    ]
  3. Run the collectstatic command to include Alpine.js in your static files:

    python manage.py collectstatic

Usage

In your templates, you can load the Alpine.js script using the provided template tag.

Example:

{% 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>

How It Works

  1. On installation, the package:

    • Copies a pre-packaged Alpine.js file to your static/js directory.
    • Attempts to download the latest version of Alpine.js from the official CDN.
  2. If the CDN is unavailable, the pre-packaged version will be used.

Development and Contribution

Contributions are welcome! Follow the steps below to get started:

  1. Clone the repository:

    git clone https://github.com/ProKelly/django-alpine.git
  2. Install dependencies:

    pip install -r requirements.txt
  3. Make your changes and submit a pull request.

License

This project is licensed under the BSD License. See the LICENSE file for details.

Author

Created and maintained by Anye Prince Kelly.

Links

About

alpine.js module for django to make it easy for developers to integrate alpine.js directly to their django projects with pip or other package installers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages