Thursday, April 21, 2011

Re: Why Django Model Filter Returns Model Object Instance Instead of QuerySet?

On Thursday, April 21, 2011 9:17:54 PM UTC+1, octopusgrabbus wrote:
I posted in the original problem.
cs_hold_rec_list = CsInvHold.objects.filter(inventory_ok=0)

How is that a problem? What's wrong with it? 
 
Right now, I can get what I need by doing this:

      qs = CsInvHold.objects.filter(inventory_ok=0)
       if qs:
           cs_list.append(['','Customer Synch Data On Hold Due To
Missing From AMR Inventory', ''])
           cs_list.append(['PremiseID', 'Endpoint ID', 'Date
Entered'])

           for each_q in qs:
               cs_list.append([str(each_q.premiseid),
int(each_q.endpointid), str(each_q.last_update)])

I want to get the entire result set without iteration through the
columns.

What does that mean?
You iterate through the members of the queryset, not the columns. Then you append a list consisting of various elements from each field in that member. What is wrong with this? What do you actually want to achieve and in what way does this not fulfill your requirement? 
 
In addition from what I read in the documentation, I was supposed to
get a QuerySet returned on a filter, not a model object reference.
I'm not sure why this is happening. 

Why *what* is happening? 

--
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