oscarmlage / django-cruds-adminlte

django-cruds is simple drop-in django app that creates CRUD for faster prototyping
BSD 3-Clause "New" or "Revised" License
424 stars 81 forks source link

customize widgets for text fields #131

Closed nekdfl closed 4 years ago

nekdfl commented 4 years ago

Hi! I just started using django-сruds. How to customize a widget for text fields? I added the decimal field to the model, created the decimalfield.html file in the columns folder. But when displayed, it looks like a counter field with up and down arrows to change the value. But I need it to be like an ordinary text field, only with numerical input. To reproduce add decimal field to any model.

nekdfl commented 4 years ago

to solve this task need add attribite 'pattern' - work as HTML5. class BanksForm(forms.ModelForm): bic = forms.CharField(widget=TextInput(attrs={'type':'text', 'pattern':'[0-9.]+'}), required=True, max_length = 15) ...Class Meta: ...

But it not numeric field. For more secure in model I did used RegexValidator