Skip to main content

Toast notifications for Django messages

Project description

Django Toastify

A modern, highly customizable toast notification system for Django, inspired by React Toastify. It integrates seamlessly with django.contrib.messages and provides a clean, responsive UI with smooth animations.

Features

  • React Toastify Aesthetic: Professional look and feel with smooth slide and fade animations.
  • Django Integration: Automatically displays django.contrib.messages.
  • Customizable: Change position, duration, theme, and more via settings.py.
  • Progress Bars: Visual indication of auto-dismiss time.
  • Interactive: Pause on hover, close button, and responsive mobile support.
  • Stackable: Smart stacking with a configurable limit to prevent screen clutter.
  • JavaScript API: Trigger toasts manually from your own scripts.
  • Theme Support: Built-in Light and Dark themes.

Installation

  1. Install the package using pip:

    pip install django-toastify
    

    (Note: If you are developing locally, use pip install -e .)

  2. Add django_toastify to your INSTALLED_APPS in settings.py:

    INSTALLED_APPS = [
        ...
        'django_toastify',
        ...
    ]
    

Configuration

You can customize the global behavior by adding a TOASTIFY dictionary to your settings.py. Here are all the available options with their defaults:

# settings.py

TOASTIFY = {
    "POSITION": "top-right",  # "top-right", "top-left", "bottom-right", "bottom-left"
    "DURATION": 3000,         # Time in milliseconds before auto-dismiss
    "MAX_TOASTS": 5,          # Maximum number of toasts shown at once
    "THEME": "light",         # "light" or "dark"
}

Available Options Detail:

Key Type Default Description
POSITION String "top-right" Corner where toasts appear.
DURATION Integer 3000 Auto-dismiss delay in ms. Set to 0 to disable (manual close only).
MAX_TOASTS Integer 5 Limits the number of toasts in the stack.
THEME String "light" Visual style: "light" or "dark".

Template Tag Overrides

You can also override these settings for specific pages directly in the template tag:

{% show_toasts position="bottom-left" theme="dark" duration=5000 %}

Usage

In Templates

  1. Load the tags and add show_toasts to your base template (usually right before </body>):

    {% load toast_tags %}
    
    ...
    
    {% show_toasts %}
    </body>
    

This will automatically render any messages sent via messages.success(), messages.error(), etc.

JavaScript API

You can also trigger toasts manually in your JavaScript code:

showToast({
    type: 'success',       // success, error, warning, info
    message: 'Hello!',     // The message text
    title: 'Greeting',     // Optional title
    duration: 5000         // Optional custom duration
});

Requirements

  • Django >= 3.2
  • Modern Browser (No IE support)

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

django_toastify-0.1.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

django_toastify-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file django_toastify-0.1.0.tar.gz.

File metadata

  • Download URL: django_toastify-0.1.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for django_toastify-0.1.0.tar.gz
Algorithm Hash digest
SHA256 786436d9073aff7dba19df7e56c1563790b0476468a1b4b27e231746f7c035a1
MD5 a6a7902481a11fa5fefad07e557ce37b
BLAKE2b-256 65d13e62aae18803d6d51930f8cdbc0b22794f9ae8e8a78b99a6b5470c40b14a

See more details on using hashes here.

File details

Details for the file django_toastify-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_toastify-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e86067fb7d85ce74e5fe9fc9d4faf1998a0129261fbee567c10a773fc2a7a83
MD5 3117b303e2cbaac289e1b75865068815
BLAKE2b-256 6ab0ac00b90640e0d5346b2b25ef5ae125d628d82bc386425a61bfec14326941

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