Re: Using ModelForm...not populating my choices

2008-05-20 Thread AdamG
Thinko in my post - it's forms.ModelChoiceField, not models.ModelChoiceField. On May 20, 2:54 pm, "Adam Gomaa" <[EMAIL PROTECTED]> wrote: > So your model is like: > >     class Folder(models.Model): >         user = models.ForeignKey(User) >         # yadda yadda > > And you want to give the

Re: Using ModelForm...not populating my choices

2008-05-20 Thread Adam Gomaa
So your model is like: class Folder(models.Model): user = models.ForeignKey(User) # yadda yadda And you want to give the user a form to sort an object into one of their own folders. So what you do is make a form like this: class ObjectSortForm(forms.Form):

Re: Using ModelForm...not populating my choices

2008-05-20 Thread chylld
I have exactly the same problem; I just want to fill the ChoiceField with a certain subset of choices based on the current user. Have you found a way to do this?? Jonathan On Apr 10, 7:21 am, ydjango <[EMAIL PROTECTED]> wrote: > Yes, They are defined in model as > > owner =

Re: Using ModelForm...not populating my choices

2008-04-09 Thread James Bennett
On Wed, Apr 9, 2008 at 4:21 PM, ydjango <[EMAIL PROTECTED]> wrote: > owner = models.ForeignKey(Participant,null=True) Not the *model* fields, the *form* fields for representing this type of relationship. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct."

Re: Using ModelForm...not populating my choices

2008-04-09 Thread ydjango
Yes, They are defined in model as owner = models.ForeignKey(Participant,null=True) all I want is to display only the Partcipants for a particular group in the choice field ( not all participants) and I am so frustrated now. eg. Participant.objects.filter(group__exact=my_group)] thanks Ashish

Re: Using ModelForm...not populating my choices

2008-04-09 Thread James Bennett
On Wed, Apr 9, 2008 at 3:30 PM, ydjango <[EMAIL PROTECTED]> wrote: > Miles and Owner are defined as foreign_key to respective tables. Yes, but did you actually look at the docs for the field types that make it easy to represent foreign keys? -- "Bureaucrat Conrad, you are technically correct

Re: Using ModelForm...not populating my choices

2008-04-09 Thread ydjango
I decided to not to use modelform and moved to using form from newforms. More coding but much more predictable behavior and easier to customize Thanks Ashish On Apr 9, 1:30 pm, ydjango <[EMAIL PROTECTED]> wrote: > for Miles, owner, > > All I need is subset of data. > I have tried everything in

Re: Using ModelForm...not populating my choices

2008-04-09 Thread ydjango
for Miles, owner, All I need is subset of data. I have tried everything in code below, passing choices , queryset, changing to choicefield etc. It just ignores everything and gets data from __unicode_ function for the foreign key table - all rows. ( I am learning Python through Django, so may

Re: Using ModelForm...not populating my choices

2008-04-09 Thread James Bennett
On Wed, Apr 9, 2008 at 2:56 PM, ydjango <[EMAIL PROTECTED]> wrote: > Not for model form, if a ChoiceField is based on foreign Key. It is > getting values from the referenced table using the __unicode__ method > in that table and ignoring the choices field passed to it. Not in this case; the

Re: Using ModelForm...not populating my choices

2008-04-09 Thread ydjango
Not for model form, if a ChoiceField is based on foreign Key. It is getting values from the referenced table using the __unicode__ method in that table and ignoring the choices field passed to it. On Mar 27, 7:57 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Thu, Mar 27, 2008 at 9:49 PM,

Re: Using ModelForm...not populating my choices

2008-03-27 Thread Greg
Brian, I tried this but still doesn't work: // class SurveyForm(ModelForm): experience = forms.ChoiceField(widget=forms.RadioSelect) class Meta: model = Survey // Nothing gets displayed in the template On Mar 27, 9:32 pm, "Brian Armstrong" <[EMAIL PROTECTED]> wrote: > On

Re: Using ModelForm...not populating my choices

2008-03-27 Thread Brian Armstrong
On Thu, Mar 27, 2008 at 9:27 PM, Greg <[EMAIL PROTECTED]> wrote: > > Hello, > My experience field by default gets displayed as a drop > down..everything works fine when it is displayed this way. However I > want the field to be displayed in my template as Radio Buttons. So I > added the

Using ModelForm...not populating my choices

2008-03-27 Thread Greg
Hello, My experience field by default gets displayed as a drop down..everything works fine when it is displayed this way. However I want the field to be displayed in my template as Radio Buttons. So I added the line ' experience = forms.CharField(widget=forms.RadioSelect) ' to my ModelClass.