Created
November 16, 2012 16:51
-
-
Save hughes/4088912 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment