Monday, October 24, 2011

Re: How to make a foreign key field of type other than int?

Hi,

On Oct 24, 10:53 am, Kayode Odeyemi <drey...@gmail.com> wrote:
> I'm sorry but it doesn't just seem to work for me. I have tried
>
> possibilities like:
>
> self.fields['branch_name'].choices =
> Branch.objects.all().values('name_branch', 'name_branch')
> self.fields['branch_name'].choices =
> Branch.objects.all().values('name_branch')

I don't think you've read Tom's responses carefully. You're still
trying to use ".values()" here, resulting in a ValuesQuerySet which
returns dictionaries instead of a regular QuerySet which returns model
objects. That simply won't ever work. And that is the reason for the
"need more than one value to unpack" error; it has to do with the
format of the results returned, nothing to do with how many results
are returned by the query.

Carl

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate