If you want to set it to always the same values, you can use the
"initial" argument on your form field.
Pseudo-example (haven't run the code, but it illustrates the solution):
class MyForm(forms.Form):
end = forms.DateField(label="Until", required=False,
initial="2009-11-12")
If you need to do it dynamically, for some reason. E.g, you don't know
until you create the form, you can override the form's __init__ and
set it there.
class MyForm(forms.Form):
end = forms.DateField(label="Until", required=False)
def __init__(self, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
self.fields['end'].initial = bar
This works for fields with one value. For multiple preselected values,
I don't know, but my first hunch would be to try to use a tuple/list
with initial values instead.
HTH,
/Håkan
8 dec 2008 kl. 17.16 skrev Abdel Bolanos Martinez:
>
> Hi,
> i'm new in django and i'm using ModelMultipleChoiceField and all
> works fine but i need to 'mark' o 'selected' some model objects from
> the queryset
>
> have ever someone did something like that???
>
>
> Abdel Bolaños Martínez
> Ing. Infórmatico
> Telf. 266-8562
> 5to piso, oficina 526, Edificio Beijing, Miramar Trade Center. ETECSA
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---