Creating a Group of Groups in Django

Posted by Greg on Stack Overflow See other posts from Stack Overflow or by Greg
Published on 2009-05-10T23:19:12Z Indexed on 2010/06/08 8:22 UTC
Read the original article Hit count: 240

Filed under:
|
|
|
|

I'm creating my own Group model; I'm not referring to the builtin Group model. I want each hroup to be a member of another group (it's parent), but there is the one "top" group that doesn't have a parent group.

The admin interface won't let me create a group without entering a parent. I get the error personnel_group.parent_id may not be NULL. My Group model looks like this:

class Group(models.Model):
    name = models.CharField(max_length=50)
    parent = models.ForeignKey('self', blank=True, null=True)
    order = models.IntegerField()
    icon = models.ImageField(upload_to='groups', blank=True, null=True)
    description = models.TextField(blank=True, null=True)

How can I accomplish this?

Thanks.

© Stack Overflow or respective owner

Related posts about python

Related posts about database