Hi, thanks for the reply! I changed it to what you suggested but it's mad about something else, now:
TemplateSyntaxError Caught an exception while rendering: 'ModelChoiceField' object has no attribute 'all' It's mad about how render it: <td>{{ form.state }}</td> I didn't read here (http://docs.djangoproject.com/en/dev/ref/forms/ fields/#modelchoicefield) that I need to do anything wacky but I guess my model has to override or define an "all" method? Thanks in advance! On Apr 17, 11:34 am, "ge...@aquarianhouse.com" <ge...@aquarianhouse.com> wrote: > try with: > > class AddressForm(forms.Form): > first_and_last_name = forms.CharField(128, 1) > street1 = forms.CharField(128, 1) > street2 = forms.CharField(128, 1) > city = forms.CharField(64, 1) > state = forms.ModelChoiceField(queryset=States.objects.all()) > > form = AddressForm() > return render_to_response('subscribe_step2.html', > { 'form' : form, > 'user_account' : user_account }) > > On Apr 17, 5:34 pm, amyhalf <afreder...@gmail.com> wrote: > > > > > > > Hi, all! > > > For the life of me I can't get anything to show up in a drop-down. > > > Here's the model: > > > class States(models.Model): > > id = models.IntegerField(unique = True, primary_key = True) > > abbrev = models.CharField(max_length = 2, blank = False) > > long_form = models.CharField(max_length = 64, blank = False) > > > def __str__(self): > > return "".join( [ self.abbrev, ' (', self.long_form, ')<br > > />' ]) > > > def __unicode__(self): > > return self.long_form > > > class Meta: > > db_table = u'states' > > > Here's the form: > > > class AddressForm(forms.Form): > > first_and_last_name = forms.CharField(128, 1) > > street1 = forms.CharField(128, 1) > > street2 = forms.CharField(128, 1) > > city = forms.CharField(64, 1) > > state = forms.ChoiceField() > > > Here's how I'm trying to populate the states: > > > form = AddressForm() > > form.state = ModelChoiceField(States.objects.all()) > > return render_to_response('subscribe_step2.html', { 'form' : form, > > 'user_account' : user_account }) > > > Now, I can successfully do this: return > > HttpResponse(States.objects.all()) and get an (albeit ugly) list of > > States in my browser so I definitely know it's working. > > > Here's the snippet from the template: > > > <tr> > > <td width="30%">State</td> > > <td>{{ form.state }}</td> > > </tr> > > > Or, while debugging, if I go: form.as_p() it shows it correctly > > made the <select> tag but nothing else. > > > I'm sure I'm doing one little thing wrong and someone can fix it in > > two minutes. Help! > > > -- > > 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 > > athttp://groups.google.com/group/django-users?hl=en. > > -- > 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 > athttp://groups.google.com/group/django-users?hl=en. -- 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=en.