public
Last active

  • Download Gist
gistfile1.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
class FolderManager(models.Manager):
# so that we can do Folder.objects...
def get_query_set(self):
return super(FolderManager, self).get_query_set().filter(is_folder=True)
 
 
class Folder(Item):
'''
this class is kind of funny looking because Items cannot have
a ForeignKey field pointing to a subclass of itself.
'''
objects = FolderManager()
 
def __init__(self, *args, **kwargs):
# override the default behavior of the is_folder field
self._meta.get_field('is_folder').default = True
super(Folder, self).__init__(*args, **kwargs)
 
class Meta:
# don't create a table
proxy = True

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.