Hi,

I've got an abstract base class like this:

class Base(models.Model):

    class Meta:
        abstract = True

    def save(self, *args, **kwargs):
        print dir(self.Meta)
        super(Base, self).save(*args, **kwargs)

and a child model class inheriting from it like this:

class Child(Base):

    class Meta:
        verbose_name_plural = "children"

When save() is called on an instance of Child, Base.save() prints the
attributes of Base.Meta instead of Child.Meta (as I may be wrongly
expecting).  I have tried changing Child.Meta to extend from Base.Meta
with the same result.

So far, the workaround seems to be to use self._meta in Base.save()
instead of self.Meta, which allows me to access the attributes of
Child.Meta.  I've noticed that the django-mptt project (on Google
Code) does this.  Is this the correct way for a base class to access a
child class's Meta attributes?

Brett

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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