Re: south migration: renaming foreign key and m2m tables

2016-05-15 Thread Michal Petrucha
On Fri, May 13, 2016 at 01:37:43AM -0700, schaf...@gmail.com wrote: > HI Michal > > I would suggest that you do this the other way around; instead of > > merging Media into Book, I'd merge Book into Media, drop Book, and > > rename Media to Book. Since you're using multi-table inheritance, the

Re: django.contrib apps migrations

2016-05-15 Thread Michal Petrucha
On Fri, May 13, 2016 at 01:01:22PM -0700, McKinley wrote: > Hi Michal, > > I know the django.contrib migrations reside within my virtualenv. What if I > wanted a fellow developer to have access to these migrations without > sharing the same django install. If i have a colleague working on their

How made worked models.Sum() together with models.Count in Django annotations?

2016-05-15 Thread Seti Volkylany
For working models.Count() I am using distinct=True. It is right worked if not models.Sum(). next code right worked. def get_queryset(self, request): qs = super(AnswerAdmin, self).get_queryset(request) qs = qs.annotate( count_likes=models.Count('likes', distinct=Tr

Re: Can't get initial value into form correctly.

2016-05-15 Thread Chris Kavanagh
Stephen, my apologies, it most certainly did work! You did make one small mistake by forgetting the quotes around the item and the form in the dict. . . like this [{'item': item, 'form': form}]. This is why it didn't work the 1st time I tried it, you were missing the quotes and I didn't catch it ti

Re: How made worked models.Sum() together with models.Count in Django annotations?

2016-05-15 Thread Simon Charette
Hi Seti, As documented this will yield the wrong results in most cases until subqueries are used instead of JOINs[1]. Cheers, Simon [1] https://docs.djangoproject.com/en/1.9/topics/db/aggregation/#combining-multiple-aggregations Le dimanche 15 mai 2016 12:42:44 UTC-4, Seti Volkylany a écrit :

Working with HstoreField in django tests

2016-05-15 Thread Denis Boyarkin
I'm using HstoreField in one of my models and when I try to test it I got an error psycopg2.ProgrammingError: ERROR: function hstore(integer[], text[]) does not exist. If I understand this problem correctly it happend because hstore extension wasn't setup in database as it was did in migratio

Re: Working with HstoreField in django tests

2016-05-15 Thread Simon Charette
Hi Denis, >From the exception it looks like the issue is not related to a missing extension but from an attempt of using and integer as a key. e.g. instance.hstore_field = {1: 'foo'} instead of instance.hstore_field = {'1': 'foo'} Cheers, Simon Le dimanche 15 mai 2016 21:11:33 UTC-4, Denis

Re: Working with HstoreField in django tests

2016-05-15 Thread Denis Boyarkin
Yes, It helped, thank you. If you're on Stackowerflow you can answer this question:this question . понедельник, 16 мая 2016 г., 9:22:50 UTC+8 пользователь Simon Charette написал: > > Hi Denis, > > From the ex

Re: How made worked models.Sum() together with models.Count in Django annotations?

2016-05-15 Thread Seti Volkylany
My new method for resolve problem not working to: (setattr(i, 'scope', i.get_scope()) for i in qs) Django not found field 'scope'. (error from traceback) -- Cannot resolve keyword 'scope' into field. Choices are: answers, author, author_id, count_answers, count_opi

How to create new field in queryset instead of usign annotation?

2016-05-15 Thread Seti Volkylany
Next code not working right def get_queryset(self, request): qs = super(QuestionAdmin, self).get_queryset(request) qs = qs.annotate( count_answers=models.Count('answers', distinct=True), count_tags=models.Count('tags', distinct=True), count_o