Hello,
Are you sure? I suppose that "childrens" is a custom manager, can you show us, the implementation of that manager? Only for performance "if len(category.childrens.all()):" -> "if category.childrens.exist():" But your problem, it's rare. Print the type of the firs element of the result list: list = BuildList(Categories.objects.filter(parent = None)) print type(list[0]) 2012/6/14 Dominis <domini...@yandex.ru> > Hello. > I need a bit help with my code. > I write a function for menu building, which should create a list of > objects, for designing it in html code. > Code of function below: > >> def BuildList(categories): >> list = [] >> for category in categories: >> if len(category.childrens.all()): >> list.append(category) >> list.append(BuildList(category.childrens.all())) >> else : >> list.append(category) >> return list >> > > I call this function for a list of categories, like this: > >> list = BuildList(Categories.objects.filter(parent = None)) >> > My function work right, but in list i get not an objects, my values have > only name of a categories. I thought it happens couse in my Category model > in __unicode__ function i place a 'return self.name', and when i call my > categories in function - it return just name. :( > What i should do for get full objects in my list? With full collection of > parameters. > I suppose this question is easy, but i just start to learn python and > django. > Thx for you time and answers. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/LwmJH2ZcRcwJ. > 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. > -- Alex Perez alex.pe...@bebabum.com *bebabum* be successful c/ Còrsega 301-303, Àtic 2 08008 Barcelona http://www.bebabum.com http://www.facebook.com/bebabum http://twitter.com/bebabum This message is intended exclusively for its addressee and may contain information that is confidential and protected by professional privilege. If you are not the intended recipient you are hereby notified that any dissemination, copy or disclosure of this communication is strictly prohibited by law. Este mensaje se dirige exclusivamente a su destinatario y puede contener información privilegiada o confidencial. Si no es vd. el destinatario indicado, queda notificado que la utilización, divulgación y/o copia sin autorización está prohibida en virtud de la legislación vigente. Le informamos que los datos personales que facilite/ha facilitado pasarán a formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene por finalidad gestionar las relaciones con usted. Tiene derecho al acceso, rectificación cancelación y oposición en nuestra oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección de e-mail l...@bebabum.com -- 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.