Skip to main content

django-toggle-switch-widget

Display toggle switch in stead of checkbox for BooleanField in django admin site.

Install

pip install django-toggle-switch-widget

Widget init parameters

  • attrs: Inherit from CheckboxInput.
  • check_test: Inherit from CheckboxInput.
  • round: Default to False. If round=True, display round switch. If round=False, display squire switch.
  • klass: Default to empty string "". Pre-setted klass are:
    • django-toggle-switch-success: Show success color (green, #06ad3d) while toggle on.
    • django-toggle-switch-warning: Show warning color (orange, #ff6a00) while toggle on.
    • django-toggle-switch-danger: Show danger color (red, #ba2121) while toggle on.
    • django-toggle-switch-dark-primary: Show dark primary color (darkcyan, #417690) while toggle on.
    • django-toggle-switch-primary: Show primary color (cadetblue, #79aec8) while toggle on.

Usage

pro/settings.py

INSTALLED_APPS = [
    ...
    'django_toggle_switch_widget',
    ...
]

app/model.py

from django.db import models

class TestModel(models.Model):
    title = models.CharField(max_length=64, help_text="Please input model title.")
    published = models.BooleanField(verbose_name="Is this test model published.")
    is_demo = models.BooleanField(help_text="Is this a demo test model?")

app/admin.py

from django.contrib import admin
from django.forms import ModelForm
from django_toggle_switch_widget.widgets import DjangoToggleSwitchWidget
from .models import TestModel

class TestModelForm(ModelForm):
    class Meta:
        model = TestModel
        fields = "__all__"
        widgets = {
            "published": DjangoToggleSwitchWidget(klass="django-toggle-switch-dark-primary"),
            "is_demo": DjangoToggleSwitchWidget(round=True, klass="django-toggle-switch-success"),
        }

class TestModeldmin(admin.ModelAdmin):
    form = TestModelForm

admin.site.register(TestModel, TestModeldmin)

Tips

  • It's better to use together with django-checkbox-normalize app.

Release

v0.1.0 2020/03/02

  • First release.

v0.1.1 2020/09/09

  • Add License.

v0.1.3 2023/09/15

  • Doc update.

v0.1.4 2025/10/27

  • Doc update.

Metadata

Release files for django-toggle-switch-widget 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-toggle-switch-widget 0.1.4
File Size Uploaded Provenance Actions
django_toggle_switch_widget-0.1.4.tar.gz 6.1 kB Without provenance Details for django_toggle_switch_widget-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-toggle-switch-widget 0.1.4
File Interpreter ABI Platform Actions
django_toggle_switch_widget-0.1.4-py3-none-any.whl Python 3 none any Details for django_toggle_switch_widget-0.1.4-py3-none-any.whl

Total release size: 12.9 kB

Release files / django_toggle_switch_widget-0.1.4.tar.gz

Download URL django_toggle_switch_widget-0.1.4.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9da81aaa7f6aab05071db54fac69fb5b0a72d78d6473a5b70d9a0330806581c8
BLAKE2b-256 checksum
How to use checksums
8ec4f7998221a6ec8c61386f5e28938dbd2f7dc2f797c61bf5ff496b1b9d803a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release files / django_toggle_switch_widget-0.1.4-py3-none-any.whl

Download URL django_toggle_switch_widget-0.1.4-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7950e83dd8a8733e6135564c05ea02f1b61bc8be9000c0ecc8158cbdae0ef6ab
BLAKE2b-256 checksum
How to use checksums
06ee0bd1fe82f724235e8a048d196ffe96201cb7847bc6e2aea53cd7dfa2e765
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Security for django-toggle-switch-widget 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page