Hi there,

I've some basic models like PERSON, GROUP and ROLE:

class PERSON (models.Model):

    first = models.CharField ('first name', max_length=256)
    last = models.CharField ('last name', max_length=256)

class GROUP (models.Model):

    name = models.CharField (max_length=256)
    members = models.ManyToManyField (PERSON, blank=True, null=True,
        through='ROLE')

class ROLE (models.Model):

    person = models.ForeignKey (PERSON)
    group = models.ForeignKey (GROUP)

Now based on those three models above I'd like to create the following
models:

class ORGANIZATION (GROUP):
    """
    An ORGANIZATION is a GROUP of PERSONs, and therefore I'd like to
    *rename* (or at least create a 'second' name for) GROUP.members
     to GROUP.people.

    """
    people = GROUP.members

class COMPANY (ORGANIZATION):

    class Meta:

        verbose_name_plural = 'companies'

    incorporation = models.CharField (max_length=16)


class EMPLOYEE (ROLE):
    """
    An EMPLOYEE is a ROLE a PERSON takes without a GROUP of PERSONs,
    e.g. a COMPANY. There I'd like to *rename* ROLE.group to the more
    specific class' member EMPLOYEE.company.

    Sine company = ROLE.group.organization.company does not work (be -
    cause apparently this *casting* down the hierarchy requires an
    object instance, I did the casting inside the constructor ..

    """
    def __init__ (self, *args, **kwargs):

        super (EMPLOYEE, self).__init__ (*args, **kwargs)
        self.company = self.group.organization.company

    profession = models.CharField (max_length=256)

Now, my question is: Are these approaches above somehow *correct* or
maybe
even *recommended* ? Is there a better solution? I wish there would be
something
like:

class EMPLOYEE (ROLE):

    company = @rename (ROLE.group.organization.company)
    profession = models.CharField (max_length=256)

where *after* the *true* renaming the original name *group* is not
available
anymore .. I read somewhere that this is not possible and it just
worms me this
imposiblity .. :.'(

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to