﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
2740	Specifying an order_with_respect_to for a self referential one to many relationship fails	anonymous	Marty Alchin	"Code example follows. Basically I'm trying to create a tree heirarchy wherein a single category can be related to multiple sub categories which can be related to sub categories, etc. 

The problem occurs when I try to make the default ordering use the parent category so as to keep all the categories grouped together.

The error I get is  ""'str' object has no attribute 'get_category_order'"". I think this is because when the ForeignKey is used, the string ""self"" is passed in to make it self referential. But apparently the Meta class is not expecting this behavior. Any suggestions?

{{{
class Category(models.Model):
   class Admin:
      pass
      
   class Meta:
      order_with_respect_to = 'parent'
      
   is_active         = models.BooleanField(default=False)
   name              = models.CharField(maxlength=100)
   parent            = models.ForeignKey(""self"", blank=True,null=True)
   search_kewords    = models.TextField(blank=True)
   
   def __str__(self):
      if self.parent:
         prefix = str(self.parent)
      else:
         return self.name
         
      return '-->'.join((prefix,self.name))
}}}"	defect	closed	Core (Other)	dev	normal	fixed			Accepted	1	0	1	0	0	0
