On Fri, Apr 22, 2011 at 1:20 AM, octopusgrabbus <old_road_f...@verizon.net>wrote:
> Here is the pertinent code: > > def reconcile_inv(request): > errors = [] > cs_list = [] > return_dc = {} > cs_hold_rec_count = 0 > try: > cs_hold_rec_count = CsInvHold.objects.count() > 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)]) > > except ObjectDoesNotExist: > cs_hold_rec_count = 0 > > My understanding is this line of code -- qs = > CsInvHold.objects.filter(inventory_ok=0) -- should return a query set. > It seems to return a CsInvHold object reference. Why does that happen? > As nobody can understand what do you mean by this, I'll ask another question. How do you know this is the object reference? What is the statement, that identified this for you? As to returning a list instead of queryset, you can use list comprehension to create a list you need. For example, if you need a list of IDs and last_updates from your queryset, you can write: ids_list = [(o.id, o.last_update) for o in qs] Or you can do just qs.values('id', 'last_update'), which will return a list of dictionaries in form {'id": 1, 'last_update': datetime(2011, 01, 01)} Also take a look at values_list() method of QuerySet. http://docs.djangoproject.com/en/dev/ref/models/querysets/#values http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.