Re: count the number of times an object / class has been instantiated
Sorry if my question is a bit off topic, sometimes my mind tends to forget that python has not been created just for django... and thanks for the answer Andy. Bastien On Apr 30, 1:40 pm, Andy Mikhailenkowrote: > Hi, your question does not seem to be related to Django. Anyway: > > class A: > cnt = 0 > def __init__(self): > A.cnt += 1 > > If you want to count saved instances of a Django model, use > MyModel.objects.count(). > > Cheers, > Andy --~--~-~--~~~---~--~~ 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 this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: count the number of times an object / class has been instantiated
Hi, your question does not seem to be related to Django. Anyway: class A: cnt = 0 def __init__(self): A.cnt += 1 If you want to count saved instances of a Django model, use MyModel.objects.count(). Cheers, Andy --~--~-~--~~~---~--~~ 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 this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
count the number of times an object / class has been instantiated
Hi, Just for curiosity, anyone knows about a way to count how many times an object or a class has been instantiated? I could add a simple counter as a method of the class but what would trigger it? thanks, Bastien --~--~-~--~~~---~--~~ 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 this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---