Re: forms.ChoiceField and empty values

2009-11-13 Thread Monika Sulik
Sorry for the double post *blush* Not sure how that happened...

The model looks something like this:

class Competition(MessageboardOwner):
name = models.CharField(max_length=256)
type = models.IntegerField(choices=COMPETITION_TYPE_CHOICES)
start = models.DateField()
end = models.DateField()
official_www = models.URLField(blank=True)

On Nov 12, 3:55 pm, rebus_  wrote:
>
> What does model Competition look like?
> Do you have choices defined in your models.py and use choices argument
> when creating that field in models?

--

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




Re: forms.ChoiceField and empty values

2009-11-12 Thread rebus_
2009/11/12 Monika Sulik :
> As I haven't had any replies so far, I'll add some more information...
>
> The empty label appears if I redefine the form like this:
>
> class CompetitionSearchForm(forms.ModelForm):
>    class Meta:
>        model = Competition
>        fields = ('name','type')
>
> It disappears again if I make the changes I need to on the fields
> (i.e. "unrequire" them):
>
> class CompetitionSearchForm(forms.ModelForm):
>    name = forms.CharField(required=False)
>    type = forms.ChoiceField(choices=COMPETITION_TYPE_CHOICES,
> required=False)
>    class Meta:
>        model = Competition
>        fields = ('name','type')
>
> Should I be defining my type field somehow differently? Or is this a
> bug in Django that I should report?
>

What does model Competition look like?
Do you have choices defined in your models.py and use choices argument
when creating that field in models?

--

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




Re: forms.ChoiceField and empty values

2009-11-12 Thread Monika Sulik
As I haven't had any replies so far, I'll add some more information...

The empty label appears if I redefine the form like this:

class CompetitionSearchForm(forms.ModelForm):
class Meta:
model = Competition
fields = ('name','type')

It disappears again if I make the changes I need to on the fields
(i.e. "unrequire" them):

class CompetitionSearchForm(forms.ModelForm):
name = forms.CharField(required=False)
type = forms.ChoiceField(choices=COMPETITION_TYPE_CHOICES,
required=False)
class Meta:
model = Competition
fields = ('name','type')

Should I be defining my type field somehow differently? Or is this a
bug in Django that I should report?

--

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




Re: forms.ChoiceField and empty values

2009-11-12 Thread Monika Sulik
As I haven't had any replies so far, I'll add some more information...

The empty label appears if I redefine the form like this:

class CompetitionSearchForm(forms.ModelForm):
class Meta:
model = Competition
fields = ('name','type')

It disappears again if I make the changes I need to on the fields
(i.e. "unrequire" them):

class CompetitionSearchForm(forms.ModelForm):
name = forms.CharField(required=False)
type = forms.ChoiceField(choices=COMPETITION_TYPE_CHOICES,
required=False)
class Meta:
model = Competition
fields = ('name','type')

Should I be defining my type field somehow differently? Or is this a
bug in Django that I should report?

--

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




forms.ChoiceField and empty values

2009-11-10 Thread Monika Sulik

Hi,

I have the following problem... I've got a form, which looks like
this:

class CompetitionSearchForm(forms.Form):
name = forms.CharField(required=False)
type = forms.ChoiceField(choices=COMPETITION_TYPE_CHOICES,
required=False)

The tuple COMPETITION_TYPE_CHOICES is used in a model class (the
purpose of the form is to search through Competition objects). It
looks something a bit like this:

COMPETITION_TYPE_CHOICES = (
(1, 'Olympic Games'),
(2, 'ISU Championships'),
(3, 'Grand Prix Series'),
)

I'd like the select widget in ChoiceField to display an empty label.
According to the documentation (http://docs.djangoproject.com/en/dev/
ref/forms/fields/#choicefield), it seems like this should happen by
default, but I don't get an empty value in the select widget at all.
Why is this?

Monika
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---