<s> from django . db import models <EOL> class Category ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> desription = models . TextField ( blank = True ) <EOL> parent = models . ForeignKey ( '<STR_LIT>' , blank = True , null = True , related_name = '<STR_LIT>' ) <EOL> slug = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> def __unicode__ ( self ) : <EOL> return self . name <EOL> class Meta : <EOL> verbose_name = ( '<STR_LIT>' ) <EOL> verbose_name_plural = ( '<STR_LIT>' ) <EOL> def get_absolute_url ( self ) : <EOL> parents = self . get_all_parents ( ) <EOL> return '<STR_LIT>' % ( '<STR_LIT:/>' . join ( [ p . slug for p in parents ] ) ) <EOL> def get_all_parents ( self ) : <EOL> "<STR_LIT>" <EOL> parents = [ ] <EOL> category = self <EOL> while True : <EOL> parents . insert ( <NUM_LIT:0> , page ) <EOL> category = category . parent <EOL> if not category : <EOL> break <EOL> return parents <EOL> def get_children ( self ) : <EOL> "<STR_LIT>" <EOL> return Category . objects . filter ( parent = self . id ) <EOL> def get_all_siblings ( self ) : <EOL> "<STR_LIT>" <EOL> return Category . objects . filter ( parent = self . category ) </s>
