Re: How do I populate a multi-select field with a single column from a model?

2010-07-31 Thread Kalys Osmonov
Area.objects.values('name','city') On Jul 31, 5:07 pm, strayhand wrote: > I want to grab a single column in a model and use it to populate a > multi-select form field. Here's the code that I'm currently using: > > areas = forms.ModelMultipleChoiceField(queryset=Area.objects.all(), > label='Prefer

Re: How do I populate a multi-select field with a single column from a model?

2010-07-31 Thread strayhand
Sweet. That did the trick. I found an example here: http://www.djangoproject.com/documentation/models/str/ # Areas Model UPDATED from django.db import models # Create your models here. class Area(models.Model): name = models.CharField(max_length=40) city = models.CharField(max_le

Re: How do I populate a multi-select field with a single column from a model?

2010-07-31 Thread strayhand
Ah... Well that's exactly what's happening. I'm getting "Area Object" for each element in the select box. I've seen the __unicode__ method on a few model examples, but my book and other resources never really showed or explained it. I'll see if I can find some explanation of it. Thanks for the clue

Re: How do I populate a multi-select field with a single column from a model?

2010-07-31 Thread Daniel Roseman
On Jul 31, 10:07 am, strayhand wrote: > I want to grab a single column in a model and use it to populate a > multi-select form field. Here's the code that I'm currently using: > > areas = forms.ModelMultipleChoiceField(queryset=Area.objects.all(), > label='Preferred Areas', help_text='Select the a

How do I populate a multi-select field with a single column from a model?

2010-07-31 Thread strayhand
I want to grab a single column in a model and use it to populate a multi-select form field. Here's the code that I'm currently using: areas = forms.ModelMultipleChoiceField(queryset=Area.objects.all(), label='Preferred Areas', help_text='Select the areas that you\'d like to serve.') This code ret