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

2011-04-22 Thread octopusgrabbus
Thanks for the links. On Apr 21, 11:56 pm, Oleg Lomaka wrote: > On Fri, Apr 22, 2011 at 1:20 AM, octopusgrabbus > wrote: > > > > > Here is the pertinent code: > > > def reconcile_inv(request): > >    errors = [] > >    cs_list = [] > >    return_dc = {} > >     cs_hold_rec_count = 0 > >     try:

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

2011-04-21 Thread Oleg Lomaka
On Fri, Apr 22, 2011 at 1:20 AM, octopusgrabbus 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.f

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

2011-04-21 Thread Javier Guerra Giraldez
On Thu, Apr 21, 2011 at 5:20 PM, octopusgrabbus wrote: > It seems to return a CsInvHold object reference. you still don't show why you think that's happening. what tests have you done? what do you mean by "it seems to"? -- Javier -- You received this message because you are subscribed to th

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

2011-04-21 Thread octopusgrabbus
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(['','Cust

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

2011-04-21 Thread Ramiro Morales
On Thu, Apr 21, 2011 at 1:37 PM, octopusgrabbus wrote: > [...] > >    try: >       cs_hold_rec_count = CsInvHold.objects.count() >       cs_hold_rec_list = CsInvHold.objects.filter(inventory_ok=0) > >    except ObjectDoesNotExist: >       cs_hold_rec_count = 0 > >    if request.method == 'POST': >

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

2011-04-21 Thread octopusgrabbus
I've asked two questions: 1) Why do I get back an Object reference, when the docs say it's a query set? 2) How can I dump that object's values into a list instead of iterating each column? On Apr 21, 5:06 pm, Daniel Roseman wrote: > On Thursday, April 21, 2011 9:17:54 PM UTC+1, octopusgrabbus w

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

2011-04-21 Thread Daniel Roseman
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.o

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

2011-04-21 Thread octopusgrabbus
I posted in the original problem. cs_hold_rec_list = CsInvHold.objects.filter(inventory_ok=0) 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 Invent

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

2011-04-21 Thread Daniel Roseman
On Thursday, April 21, 2011 7:52:02 PM UTC+1, octopusgrabbus wrote: > > I have been able to narrow my question down. I can pull individual > columns from the returned model object reference. How can I get all > those columns in a list. Wrapping in a list() function returns an > error object is n

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

2011-04-21 Thread octopusgrabbus
I have been able to narrow my question down. I can pull individual columns from the returned model object reference. How can I get all those columns in a list. Wrapping in a list() function returns an error object is not iterable error. On Apr 21, 12:37 pm, octopusgrabbus wrote: > Here is my mode

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

2011-04-21 Thread octopusgrabbus
I've also added this to force the QuerySet to evaluate, and I'm still getting the object reference: for list_element in CsInvHold.objects.filter(inventory_ok=0): cs_list.append(list_element) On Apr 21, 12:37 pm, octopusgrabbus wrote: > Here is my model (shortened for brevity)

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

2011-04-21 Thread octopusgrabbus
BTW: I had already noticed the mention that QuerySets are lazy here http://docs.djangoproject.com/en/1.2/topics/db/queries/#field-lookups, but how to I cause the query set to access the database. A print isn't going to help me when I want to send a list to a function that will write it into a file.

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

2011-04-21 Thread octopusgrabbus
Here is my model (shortened for brevity). It was generated by inspectdb. I am running Django 1.2 with mod_wsgi, on Ubuntu 10.04 and apache2. class CsInvHold(models.Model): action = models.CharField(max_length=3, db_column='Action', blank=True) # Field name made lowercase. . . . inventory_o

Re: django model filter

2010-09-03 Thread Justin
Well, I'm glad it works. Please post, if you want to, a cleaner solution if you find it! -Justin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group,

Re: django model filter

2010-09-03 Thread spearsear
I did it in your way, it certainly works. But I feel this is a little ugly. My query is way more complicated that the example here so I had to do if a lot. On Sep 3, 8:29 am, Justin wrote: > Off the top of my head, you could do something like this: > > import math > import django.db.models.Q > >

Re: django model filter

2010-09-03 Thread Justin
Off the top of my head, you could do something like this: import math import django.db.models.Q jeff_abs = math.fabs(jeff.balance) #get the absolute value of jeff's balance Account.objects.get(Q(balance__gt=jeff_abs) | Q(balance__lt=(jeff_abs * -1))) This way you pick up all positive balances g

django model filter

2010-09-02 Thread spearsear
Account.objects.filter(balance__lt=20) selects accounts with balance less than $20 Account.objects.filter(balance__lt=jeff.balance) selects accounts with balance less than the balance of jeff's account Now, How do I do this? accounts with balance whose absolute value is greater than the absolute

Re: Django model filter

2008-12-20 Thread Fridrik Mar Jonsson
Hi Kev, > Im a bit confused with django model api and cannot seem to figure out > how to do: > > SQL WHERE (user == username AND friend == friend) OR (user == friend > AND friend == user). Please see the following piece of documentation: http://docs.djangoproject.com/en/dev/topics/db/queries/

Django model filter

2008-12-20 Thread kev
Hello, Im a bit confused with django model api and cannot seem to figure out how to do: SQL WHERE (user == username AND friend == friend) OR (user == friend AND friend == user). How would django model api write that code? Thanks, Kevin --~--~-~--~~~---~--~~ You