Re: QuerySet for related models

2016-08-04 Thread Constantine Covtushenko
Hi M Hashmi, I believe that you are looking a way to use aggregation on related model. You should try the following snitppet: `trending_products = Product.objects.aggregate(hit=Max('hits__hits'))[:6]` (see more info here ) This will

Re: QuerySet for related models

2016-08-04 Thread M Hashmi
Hello Todor, I followed your directions and used https://docs.djangoproject.com/ja/1.9/ref/contrib/contenttypes/ for reference but I got stuck at error 'GenericForeignKey' object has not attribute 'get_lookup'. I tried Product.objects.aggregate(Count('hits'))[:6]. In my models.py I got

Re: QuerySet for related models

2016-08-04 Thread M Hashmi
Thank you Constantine, I got this mistake fixed and this was really bad mistake from my side. Now with your proposed scenario I am trying to get it work with "trending_products = Product.objects.all().order_by('hits__hits')[:6]" but still it isn't giving me sort by max hits as I used annotate

Re: QuerySet for related models

2016-08-04 Thread M Hashmi
Thanks Todor as this make senseall I need is to get the Hitcount's hits presented as local variable to Product model so in queryset I can set order_by. I will try this and will post results. On Thursday, August 4, 2016 at 2:07:53 PM UTC-7, Todor Velichkov wrote: > > My field

Re: parallel test running throwing pickleError

2016-08-04 Thread Jonas Trappenberg
You can debug by adding code like this to django/test/runner.py just after it determined the args (around line 315 in django 1.9): import pickle for arg in args: print(arg) pickle.dumps(arg) I found that pickle raises the same exceptions as cPickle, but, since it's all Python, lets you

Re: WSGI question

2016-08-04 Thread John
Hi Jonty, You can only have one version of mod_wsgi installed per apache instance, so you need to uninstall the 2.7 version and install the 3.4 version. On Ubuntu, the libapache2-mod-wsgi-py3 package is what you are looking to have installed. John On 05/08/16 00:37, Jonty Needham wrote: > Sorry

WSGI question

2016-08-04 Thread Jonty Needham
Sorry if this isn't for here, but I've somehow got the wrong version of python running with mod_wsgi --2.7 instead of 3.4, so none of the 3.4 libraries work, like collections or datetime. Where do I look to change this? -- You received this message because you are subscribed to the Google

Re: QuerySet for related models

2016-08-04 Thread Constantine Covtushenko
Please check my notes below: On Thu, Aug 4, 2016 at 10:42 PM, M Hashmi wrote: > My field hits=models.ForeignKey(Hitcount) means that my Product model has > a related model with multiple fields and all the products in Product model > will have one or more hit records. >

Re: QuerySet for related models

2016-08-04 Thread Todor Velichkov
> > My field hits=models.ForeignKey(Hitcount) means that my Product model has > a related model with multiple fields and all the products in Product model > will have one or more hit records. Instance of Product model will save a > hit from end user by session/ip/user etc. Honestly, I don't

Re: QuerySet for related models

2016-08-04 Thread M Hashmi
My field hits=models.ForeignKey(Hitcount) means that my Product model has a related model with multiple fields and all the products in Product model will have one or more hit records. Instance of Product model will save a hit from end user by session/ip/user etc. -- You received this message

Re: QuerySet for related models

2016-08-04 Thread Constantine Covtushenko
Hi M Hashmi, As I see your model scheme built with meaning that 1 record of HitCount relates to many records of Product. And in your queries you try to select all products that relate to 5 topmost HitCounts. Am I correct? Will be waiting for your response. On Thu, Aug 4, 2016 at 6:41 PM, M

QuerySet for related models

2016-08-04 Thread M Hashmi
I know that count only can be applied for an IntegerField or FloatField but I've created a ForeignKey to another model which contains hitcounts. Now I need to filter results by max count from related model and I couldn't dot it. models.py: class Product(models.Model): title =

Re: How do templates automatically convert dates to local timezone?

2016-08-04 Thread João Sampaio
You should probably look in the code of models.DateTimeField, models.DateField and models.TimeField. On Wed, Aug 3, 2016 at 6:06 PM, Robert Rollins wrote: > Perhaps I wasn't clear. I know *what* Django does with timezone-aware > dates. I just want to know *how* it does

Re: null=True and blank=False within model fields

2016-08-04 Thread James Schneider
On Aug 3, 2016 5:18 PM, "Kevin Brown" wrote: > > Within Django REST framework a discussion sparked about how the combination of null=True and blank=False should be handled with validation. What side is right in the discussion isn't the question here. > > Are there cases