I should have included that the reason I'm using a `MultipleChoiceField` 
instead of a `ModelMultipleChoiceField` here is because I want the POSTed 
variable to be the business service name (string) not the primary key of 
the selected record.

j


On Thursday, February 15, 2018 at 8:56:56 AM UTC-6, jason...@gmail.com 
wrote:
>
> Hello everyone,
>
> I have a form field that is pulling choices from the database:
>
> class FooJBossForm(Form):
>     biz_service = MultipleChoiceField(
>         choices=BizService.objects.filter(
>             biz_unit__bu_name='Foo',
>         ).order_by('bs_name').values_list('bs_name', 'bs_name').distinct
> (),
>         required=False,
>         label='Business Service',
>         widget=SelectMultiple(attrs={'class': 'form-control'}),
>     )
>
>     ...
>
> This worked great until someone else on my team attempted to start with a 
> fresh DB and was getting "relation does not exist" errors trying to do the 
> initial import.
>
> Commenting out these "choices=" parameters in `forms.py` fixes the issue.  
> What's the right way to go about populating form field choices from the DB 
> at access time?
>
> Thanks,
>
> j
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2fec400e-e20b-4030-acd5-9b1e2f9db6ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to