Django Custom select widget
Project description
django-CustomSelectWidget
This is a custom Select Widget for django forms and modelforms. This widget will enable you to have a select field in HTML that can take free text value along with a limited
select options. the selectable option can be selected by user or if need be, the user can type their own free text in the field. This widget works with django.forms.CharField.ChildProcessError
Supported Python versions: 3.4+
Supported Django versions: 2.0+
Installation
Install with pip
$ pip install django-CustomSelectWidget
Configure your models.py or forms.py
from django.forms.models import ModelForm
from customselectwidget.customselectwidget import CustomSelectWidget
from django import forms
# ...
class MyModelForm(ModelForm):
# .....
my_field=forms.CharField(required=False,max_length=200, label='Please select your task')
def __init__(self, *args, **kwargs):
_type_list = kwargs.pop('data_list', None)
super(MyModelForm, self).__init__(*args, **kwargs)
# the "name" parameter will allow you to use the same widget more than once in the same
# form, not setting this parameter differently will cuse all inputs display the
# same list.
self.fields['my_field'].widget = CustomSelectWidget(data_list=['option 1','option 2','option 3'], name='type-list')
In your settings.py
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
#.....................#
'customselectwidget',
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file django_customselectwidget-0.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: django_customselectwidget-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ee5371ac6e6f1f431b9d792755f99220609d0c38fdc30f4ab59ab77e438f3f4 |
|
MD5 | 834a70a40a624a62e5de153bde30eb3b |
|
BLAKE2b-256 | 03ac79698fec511910f43704fd1228128dfebc929e3c72a947f3ee4bba8fb8be |