Weird behaviour using django localflavor CAProvinceSelect
My first time using localflavor in django and got a strange thing today! I have a form and was trying to user CAProvinceSelect, however, dont know why It wasnt render anything, to ilustrade, this was my code:
from django.contrib.localflavor.ca.forms import CAProvinceSelect
class RegistrationForm(UserCreationForm):
province = CAProvinceSelect()
After I got boring to try making this work, I changed my code to:
from django.contrib.localflavor.ca.forms import CAProvinceField
from django.contrib.localflavor.ca.ca_provinces import PROVINCE_CHOICES
class RegistrationForm(UserCreationForm):
province = CAProvinceField(widget=forms.Select(choices=PROVINCE_CHOICES))
And it worked !!!!
My question here is, why? does someone got that before?! Shouldnt 'CAProvinceSelec开发者_JAVA百科t' create a SelectField with that choices?!?
please see here: http://django-irc-logs.com/2011/aug/20/#113904
CAProvinceSelect is a widget, you need to use CAProvinceField to get output:
province = CAProvinceField(widget=CAProvinceSelect)
精彩评论