Re: Calculation for each object in a QuerySet

2011-08-06 Thread nixlists
Thank you so much guys, your suggestions are very helpful. Bruno, others: I really appreciate your help. -- 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

Re: Calculation for each object in a QuerySet

2011-08-05 Thread nixlists
On Fri, Aug 5, 2011 at 5:14 PM, Subhranath Chunder wrote: > Your model declarations are very confusing for me, and seems to be running > around in circles. Very difficult to follow for me. > The logical relationships are not clear. So, how to arrive at the > 'rebate_pct' and

Re: Calculation for each object in a QuerySet

2011-08-05 Thread nixlists
On Fri, Aug 5, 2011 at 7:51 AM, bruno desthuilliers wrote: > Without more informations about your models (and specially the > relationships), it's going to be rather difficult. As a general > consideration, if your Claim model can access these other models thru >

Re: Calculation for each object in a QuerySet

2011-08-04 Thread nixlists
On Thu, Aug 4, 2011 at 5:31 PM, Javier Guerra Giraldez <jav...@guerrag.com> wrote: > On Thu, Aug 4, 2011 at 3:53 PM, nixlists <nixmli...@gmail.com> wrote: >> What's the correct way to write the view then? Any work-arounds? > > - collect the modified objects to a list,

Re: Calculation for each object in a QuerySet

2011-08-04 Thread nixlists
On Thu, Aug 4, 2011 at 4:47 PM, Javier Guerra Giraldez wrote: > you're modifying the 'claim' objects cached by the queryset.  as soon > as the queryset loads another part of the table (typically it loads in > 21-record chunks) or if it's clone()'d (happens a lot), it will >

Re: Calculation for each object in a QuerySet

2011-08-04 Thread nixlists
On Thu, Aug 4, 2011 at 4:10 PM, Javier Guerra Giraldez <jav...@guerrag.com> wrote: > On Thu, Aug 4, 2011 at 2:14 PM, nixlists <nixmli...@gmail.com> wrote: >> I need to rewrite the view so that for each object I need to make a >> simple calculation based on the data i

Re: Calculation for each object in a QuerySet

2011-08-04 Thread nixlists
On Thu, Aug 4, 2011 at 3:17 PM, Jacob Kaplan-Moss wrote: > Well, without more details about your model(s) and what calculation > you'd like to make it's impossible to give you a specific answer. > However, you may want to take a look at Django's > aggregation/annotation

Calculation for each object in a QuerySet

2011-08-04 Thread nixlists
Hi. I have a view that currently simply takes a QuerySet and displays it using pagination with the list_detail.object_list generic method: return list_detail.object_list( request, queryset = cset, paginate_by=30 ) I need to rewrite the view so that for

Humanizing decimals in templates

2011-07-29 Thread nixlists
Hi. The humanize module - https://docs.djangoproject.com/en/1.3/ref/contrib/humanize/ does not support humanizing decimal values similar to 'intcomma', only integers. Is there an extension to do so, and if not how would one write one? How would one use this

Re: Optimization of a Large QuerySet iteration

2011-07-26 Thread nixlists
On Tue, Jul 26, 2011 at 7:42 AM, Roman Klesel wrote: ... > The main question you may ask yourself may be whether or not you > really want to have django do the whole calculation thing. Many > database engines have very powerful aggregation capabilities, support > for

Re: Optimization of a Large QuerySet iteration

2011-07-26 Thread nixlists
On Tue, Jul 26, 2011 at 9:52 AM, Tom Evans wrote: >  p_dict = dict(contract_products.values_list('product', 'wac__wac')) > > This should cut down the number of queries in the view significantly. Thanks! This is much better than what I had. -- You received this message

Re: Is there a way to insert data from a csv file into my database?

2011-07-25 Thread nixlists
Wow, these are great. I was thinking about having to write something much more basic, now I have something to learn from. Thanks for sharing! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Optimization of a Large QuerySet iteration

2011-07-24 Thread nixlists
Hi. I am a newbie :) This is probably not a very Django-like design at this point, but the goal is to move towards it from a legacy-type design DB. My models are currently set up something like the following (since there is quite a bit of trial-and-error database design and data import work to

Re: Is there a way to insert data from a csv file into my database?

2011-07-24 Thread nixlists
On Sun, Jul 24, 2011 at 2:46 PM, Jarilyn Hernandez wrote: > Hi, Thanks for the response. My problem is that I have my tables created on > django. All I want is to import some data from a csv file to these tables I am using HeidiSQL with MySQL for this, but a script

Re: Database Design Question

2011-07-22 Thread nixlists
On Thu, Jul 21, 2011 at 5:35 PM, Marc Aymerich wrote: > > ups, I think it should be: > contract.products.filter(id=Y).values_list('rebate_pct', flat=True) > product.contractproduct_set.filter(id=X).values_list('rebate_pct', > flat=True) Thanks. The first one does not work

Re: Database Design Question

2011-07-21 Thread nixlists
On Thu, Jul 21, 2011 at 4:30 PM, Jani Tiainen wrote: > ContractProduct.objects.all() > Following might work also (not sure, but is easy to test in shell for > example): > for c in Contract.objects.all(): >     for cp in c.contractproduct_set.all(): >         print c,

Re: Database Design Question

2011-07-21 Thread nixlists
On Thu, Jul 21, 2011 at 2:17 PM, Jani Tiainen wrote: > Hi, > So you want to tie Contract with Product(s) with rebate_pct? You then need > custom intermediary m2m table say "ContractProduct" >