mwebs wrote:
> Thanks Nathaniel,
>
> but where and how do I pass the Queryset? From my view?
> I am sorry but I dont understand completly
>
> class MyModelChoiceField(forms.ModelChoiceField):
> def label_from_instance(self, obj):
> return "My Object #%i" % obj.id
>
>
> class PictureFor
mwebs wrote:
> Hello,
>
> I am trying to do something like this
>
> class PictureForm(forms.Form):
> image = forms.ImageField(label='Picture')
> gallery= forms.ChoiceField(Gallery.objects.all())
>
> this just works fine, but I only want to pass several Galleries to the
> C
Thanks Nathaniel,
but where and how do I pass the Queryset? From my view?
I am sorry but I dont understand completly
class MyModelChoiceField(forms.ModelChoiceField):
def label_from_instance(self, obj):
return "My Object #%i" % obj.id
class PictureForm(forms.Form):
image
On Jun 26, 7:53 am, mwebs <[EMAIL PROTECTED]> wrote:
> gallery = forms.ChoiceField(Gallery.objects.filter( ...))
You want to use a ModelChoiceField [1] instead of a ChoiceField. It
takes a QuerySet as an argument::
class PictureForm(forms.Form):
...
gallery = forms.ModelChoic
model choice field
http://www.djangoproject.com/documentation/newforms/#fields-which-handle-relationships
On Jun 26, 9:53 am, mwebs <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am trying to do something like this
>
> class PictureForm(forms.Form):
> image = forms.ImageField(label='Pict
Hello,
I am trying to do something like this
class PictureForm(forms.Form):
image = forms.ImageField(label='Picture')
gallery= forms.ChoiceField(Gallery.objects.all())
this just works fine, but I only want to pass several Galleries to the
ChoiceField...
something like:
6 matches
Mail list logo