Skip to content

Allow to use comma and period as separator in django forms.

License

Notifications You must be signed in to change notification settings

arcamens/django-commadecimal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-commadecimal

Allow to use comma and period as separator in django forms.

Install

pip install django-commadecimal

Note: I have tested it with django==1.11.

Usage

The commadecimal packages contains a module widgets that contains the CommaWidget class. Such a class should replace the DecimalField widget.

Example of basic usage:

from django import forms
from commadecimal.widgets import CommaDecimal

class ExampleForm(forms.Form):
    value = forms.DecimalField(help_text='''Some decimal 
    value with comma or period.''', widget=CommaDecimal)

If you were using ModelForm then you could just do:

class ModelName(forms.ModelForm):
    class Meta:
        # Other attributes here.
        widgets = {'fieldname': CommaDecimal}

The repository contains the demo project whose core_app application implements a working example of commadecimal application.