[Django]-Inherit and modify a `Meta` class

5👍

Try:

class ApplicationTable(ItemTable):
    class Meta:
        model = Application
        fields = ItemTable.Meta.fields + ('jira_bucket_name',)

You’ll have the same problems extending Meta in a table, as you will in a normal Django model.

4👍

You didnt add , (comma) to one-element tuple. Try to change this line Meta.attrs['fields'] += ('jira_bucket_name') in ApplicationTable to:

Meta.attrs['fields'] += ('jira_bucket_name',)

if it didnt help try to create Meta class outsite model class definition:

class ItemTableMeta:
    model = Item
    attrs = {"class":"paleblue"}
    fields = ('name', 'primary_tech', 'primary_biz', 'backup_tech', 'backup_biz')

class ApplicationTableMeta(ItemTableMeta):
    model = Application
    fields = ItemTableMeta.fields + ('jira_bucket_name',)


class ItemTable(tables.Table):
    #...
    Meta = ItemTableMeta

class ApplicationTable(ItemTable):
    #...
    Meta = ApplicationTableMeta
👤ndpu

0👍

You may need to take this up with the django-tables author. This is not a problem with standard Django.

Leave a comment