SELECT s1.*, count(s2.id_sections)
FROM sections s1
LEFT JOIN sections s2 ON s2.parent = s1.id_sections
WHERE s1.parent = 0
GROUP BY s1.id_sections
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class Foo(object):
def __init__(self, name):
self.name = name
def __str__(self):
return 'str: %s' % self.name
def __unicode__(self):
return 'uni: %s' % self.name.decode('utf-8')
def __repr__(self):
return 'repr: %s' % self.name
a = 'Елена S'
b = Foo(a)
print(str(b))
print(unicode(b))
print(repr(b))
str: Елена S
uni: Елена S
repr: Елена S