Re: model inheritance - getting data from child objects

2008-11-14 Thread Enrico
Maybe this could help: http://www.djangosnippets.org/snippets/1187/ --~--~-~--~~~---~--~~ 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

Re: model inheritance - getting data from child objects

2008-11-08 Thread euglena
Use ContentType. Read about it in django documentation On Nov 8, 2:03 am, Alistair Marshall <[EMAIL PROTECTED]> wrote: > On Nov 7, 4:19 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote: > > > I don't know if it's clever or stupid, but this is what I have done in a > > similar situation: > > It

Re: model inheritance - getting data from child objects

2008-11-07 Thread Alistair Marshall
On Nov 7, 4:19 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote: > I don't know if it's clever or stupid, but this is what I have done in a > similar situation: > It appears to be a nice solution - it throws an error If I try to get_related() on a generic non-specialised place rather than just

Re: model inheritance - getting data from child objects

2008-11-07 Thread Gerard flanagan
Alistair Marshall wrote: > As I said, I have the function named the same in each child class but > I need to be able to access it from a list of all the Places. > > My current thinking is just a long list of try, except: statements > attempting to call the subclass from the Place model but this

Re: model inheritance - getting data from child objects

2008-11-06 Thread Pawel Pilitowski
On 07/11/2008, at 3:01 AM, Alistair Marshall wrote: On Nov 6, 2:22 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote: > If all worker classes (cook, waiter, ...) are subclassed from Worker, > something like this should work: Worker.objects.filter(workplace=...) > Unfortunately the function that

Re: model inheritance - getting data from child objects

2008-11-06 Thread Alistair Marshall
On Nov 6, 2:22 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote: > If all worker classes (cook, waiter, ...) are subclassed from Worker, > something like this should work: Worker.objects.filter(workplace=...) > Unfortunately the function that each child will run is a bit more complicated than just

Re: model inheritance - getting data from child objects

2008-11-06 Thread Thomas Guettler
I have never used model inheritance, but I read the documentation If all worker classes (cook, waiter, ...) are subclassed from Worker, something like this should work: Worker.objects.filter(workplace=...) (Given that workers only work for one workplace) HTH, Thomas Alistair Marshall

model inheritance - getting data from child objects

2008-11-06 Thread Alistair Marshall
Using the example in the django writing models documentation [1] I wish to get a list of all the places, then calculate a value that depends on what the type of place it is. Say in my restraunt I have a function get_workforce() which returns a list of all the people that work in the restaraunt.