Created
February 26, 2013 15:06
-
-
Save 0atman/5039091 to your computer and use it in GitHub Desktop.
A generic grouping, other models m2m this.
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 Group(models.Model): | |
""" | |
A generic grouping, other models m2m this. | |
""" | |
parent = models.ForeignKey('self', null=True, blank=True, related_name="children") | |
slug = models.SlugField(max_length=100, help_text="The slug field.", default="") | |
name = models.CharField(max_length=100) | |
def __unicode__(self): | |
return u"%s/%s" % ( | |
(lambda g: g.parent if g.parent else "")(self), | |
self.slug | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
unicode()
returns easy to read names like: