On Friday, August 19, 2016 at 5:20:45 AM UTC-5, Michal Petrucha wrote:
>
> Could you show us the code of with_user? Maybe it does not return an 
> unevaluated queryset? 
>
>  
    def with_user(self):
        all_agents = EconomicAgent.objects.all()
        ua_ids = []
        for agent in all_agents:
            if agent.users.all():
                ua_ids.append(agent.id)
        return EconomicAgent.objects.filter(id__in=ua_ids)

Moving the call to with_user to form.__init__ solved the problem in the 
form ModelChoiceField.

These questions remain unanswered, although I intend to do a bunch more 
testing:

   1. How pervasive is this problem? Does it affect template variables like 
   {{ object.foreign_key_method }} where the foreign_key_method returns a 
   queryset?
   2. Is this behavior clearly documented anywhere?

-- 
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/e21e3ec0-dfba-4d0f-a4f0-828a552ee0af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to