Re: Django 1.5 app had subclasses without tables without proxy and now 1.6 won't sync with proxy

2022-04-04 Thread Antonis Christofides
This looks strange, although I'm not familiar with exactly this particular use 
case. I'm assuming you are referring to multi-table inheritance. Are you certain 
Django 1.5 wasn't creating these tables? Was it using migrations or South maybe? 
(Obviously I don't remember when Django started supporting migrations.) When you 
say it tries to query these tables, when does it attempt to do so? Could you 
post an example of a subclasss, preferably with its base class?




On 04/04/2022 09.09, John Abraham wrote:

Hello. We're migrating someone else's app that was at Django 1.5.12 and we're 
trying to bring it more up-to-date, step-by-step, starting with Django 1.6.11.


There's an odd thing. There were a bunch of subclasses of a Model class, that 
didn't have any database fields. Django wasn't creating nor using tables for 
them at 1.5.12. But, Django 1.6.11 keeps trying to query these non-existent 
tables for these subclasses, expecting them to have a single field which would 
just be the pointer to their superclass.


It seems the proper way to tell Django not to use tables for a class is to set:

class Meta:
proxy = True

But if we put this in, then when we run syncdb it strangly tries to query the 
base classes before any tables are created at all in the database.


Any old-timers run into anything like this? Did Django 1.5 not need the proxy 
= True in the meta to avoid creating tables for subclasses of Models that 
didn't add any fields?


They are using InheritanceManager from django_model_utils.

Thanks for any help! Banging our heads against the wall on this one for quite 
a while now...

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an 
email to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/45eec62d-a27c-4b5e-b8ff-6fc2981efa17n%40googlegroups.com 
.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e18bf6d7-e384-8a10-91dc-55246488e938%40antonischristofides.com.


Django 1.5 app had subclasses without tables without proxy and now 1.6 won't sync with proxy

2022-04-04 Thread John Abraham
Hello. We're migrating someone else's app that was at Django 1.5.12 and 
we're trying to bring it more up-to-date, step-by-step, starting with 
Django 1.6.11.

There's an odd thing. There were a bunch of subclasses of a Model class, 
that didn't have any database fields. Django wasn't creating nor using 
tables for them at 1.5.12. But, Django 1.6.11 keeps trying to query these 
non-existent tables for these subclasses, expecting them to have a single 
field which would just be the pointer to their superclass.

It seems the proper way to tell Django not to use tables for a class is to 
set:

class Meta:
proxy = True

But if we put this in, then when we run syncdb it strangly tries to query 
the base classes before any tables are created at all in the database.  

Any old-timers run into anything like this? Did Django 1.5 not need the 
proxy = True in the meta to avoid creating tables for subclasses of Models 
that didn't add any fields?

They are using InheritanceManager from django_model_utils. 

Thanks for any help! Banging our heads against the wall on this one for 
quite a while now...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/45eec62d-a27c-4b5e-b8ff-6fc2981efa17n%40googlegroups.com.


Re: django queryset - Get the data particular to current year only

2022-04-04 Thread Trippy Samurai
Thanks for the reply Brother but it's already solved

On Sunday, 3 April 2022 at 12:05:39 UTC+5:30 sutharl...@gmail.com wrote:

> I think this is related to your query
> https://stackoverflow.com/a/28101722/8882295
>
> On Thu, 31 Mar 2022 at 11:22, Trippy Samurai  
> wrote:
>
>>
>> 
>>
>> I have my query written to get some thing from database and display on my 
>> website that query is getting all the data from db but what if i want to 
>> get the data particular to current year only
>>
>>
>> def get(self, request, *args, **kwargs):
>> filters = self.get_filters()
>>
>> result = Model.objects.all().filter(*filters).distinct().aggregate(
>> t=Sum('t'),
>> b=Sum('b'),
>> )
>>
>> result2 = Model.objects.all().filter(*filters).distinct().aggregate(
>> past_due=Sum('balance', filter=Q(due_date__lt=timezone.now()))
>> )
>>
>> zero = Decimal('0.00')
>>
>> total = result['t'] or zero
>> balance = result['b'] or zero
>> past_due = result2['past_due'] or zero
>> amount_received = t - b
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/f0959467-786f-4701-9d68-abd2e54c3aaan%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/14733a49-9175-4fa5-a09e-0de0c6881ccdn%40googlegroups.com.