Skip to content

mattiagiupponi/django-togglefield

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-togglefield

Simple library to enable togglefield in Django

How to enable the app:

  1. Install the library from Github
pip install git+https://github.com/mattiagiupponi/django-togglefield.git@master
  1. Enable the app in your Django Project by adding it into the INSTALLED_APPS
INSTALLED_APPS = [
    ....,
    'togglefield',
    ....
]
  1. Define the field into your form:
from django.forms import forms
from togglefield.forms import ToggleSwitchFormField

class FormWithToggle(forms.Form):
    your_name = forms.CharField(label='Your name', max_length=100)
    toggle = ToggleSwitchFormField(required=False)
  1. Render your form in your html page:

views.py

def index(request):
    context = {
        "form": FormWithToggle
    }
    return render(request, 'app/index.html', context)

index.html

{{form.as_p}}
  1. Enjoi your field

About

Simple library to enable togglefield in Django

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published