That's rigth you hit the point!!!!
followed your advice and with these lines i resolved my problem, got
modelform filtered by a custom query !!!!
yahooooo!!!!
the model (part of it)
class Indicacion(models.Model):
'''
@author: Abel Bolaños Martínez
@contact: [EMAIL PROTECTED]
'''
emisor = models.ForeignKey(Emisor)
responsables = models.ManyToManyField(Responsable)
participantes = models.ManyToManyField(Participante,blank=True)
the form (the hot line):
class indicacionForm(ModelForm):
'''
Formulario del modelo que mapea a la clase Indicacion
@author: Abel Bolaños Martínez
@contact: [EMAIL PROTECTED]
'''
class Meta:
model = Indicacion
def __init__(self, *args, **kwargs):
super(indicacionForm, self).__init__(*args, **kwargs)
self.fields['responsables'].queryset =
devuelveTodosNoBorrados(Responsable) (this is a personal query)
self.fields['emisor'].queryset =
devuelveTodosNoBorrados(Emisor) (this is a personal query)
self.fields['participantes'].queryset =
devuelveTodosNoBorrados(Participante) (this is a personal query)
On Mon, 2008-12-08 at 21:00 +0100, Håkan Waara wrote:
> Yes, that's what my reply to you was about. The below examples work
> for ModelChoiceField, you only need to use the same technique on a
> ModelMultipleChoiceField, where I - like I wrote - guess you can use a
> tuple of initial values, e.g. ("foo", "bar").
>
> /Håkan
>
> 8 dec 2008 kl. 18.30 skrev Abdel Bolanos Martinez:
>
> > what I want is use ModelMultipleChoiceField with a queryset but I
> > need that some of the <options> of the <seletc> generated be mareked
> > as <selected="selected">,
> >
> > Bite?
> >
> >
> > On Mon, 2008-12-08 at 17:36 +0100, Håkan Waara wrote:
> >>
> >> 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
> >> >
> >> > >
> >>
> >>
> >>
> >>
> >
> > Abdel Bolaños Martínez
> > Ing. Infórmatico
> > Telf. 266-8562
> > 5to piso, oficina 526, Edificio Beijing, Miramar Trade Center. ETECSA
> >
> > >
>
>
> >
>
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
-~----------~----~----~----~------~----~------~--~---