Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mailarchis/490625 to your computer and use it in GitHub Desktop.
Save mailarchis/490625 to your computer and use it in GitHub Desktop.
class AddressWidget(forms.MultiWidget):
"""
Custom widget for Custom Field AddressField
"""
def __init__(self, country_choices, city_choices, locality_choices, attrs=None):
widgets = (forms.TextInput(), forms.TextInput(), forms.Select(attrs=attrs, choices=country_choices), forms.Select(attrs=attrs, choices=city_choices),forms.Select(attrs=attrs, choices=locality_choices), forms.TextInput())
super(AddressWidget, self).__init__(widgets, attrs)
def decompress(self, value):
if value:
return value
return [None,None,None,None,None,None]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment