Saturday, December 31, 2011

USStateField default value

I wanted to have a select box for the state with California as the
default. I first tried in my model the following:

state = USStateField(blank=True, default='CA')

This gave me the error "TypeError: __init__() got an unexpected
keyword argument 'default'".

But the following works (i.e., California is the default and I have a
nice select box):

state = models.CharField(blank=True, max_length=2,
choices=STATE_CHOICES, default='CA')

Could this be a bug? I am using 1.3.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment