Is there a way to adjust inherited verbose_name and help_text in child tables depending on which child table is inheriting?

Sergiy Khohlov very kindly offered a generic OOP solution[1] to a recent question I asked "how can an abstract class know which class inherits it"

I tried Sergiy's solution but couldn't get it working. However, I'm sure this has been solved before. Maybe Sergiy's solution would have worked if I coded it properly. Here is the problem ...

class Flavours(models.Model):
flavour = models.CharField(max_length=99, verbose_name="to be set by inheritor", help_text="to be set by inheritor") sauce = models.CharField(max_length=99, verbose_name="to be set by inheritor", help_text="to be set by inheritor")
    class Meta:
        abstract = True

class Pizza(Flavours):
    base = models.CharField(max_length=99)

class Pasta(Flavours):
    pasta_shape = models.CharField(max_length=99)

Thanks

Mike




[1] Thanks Sergiy ...

class ParentClass(object):
    def __init__(self, name):
        print "Constructor parent"
        print "Called from ", name
class ChildClass(ParentClass):
    def __init__(self):
        super(ChildClass,self).__init__("Child")
        print "Child Constructor"



--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to