Django with FeinCMS can show anything from tables and it looks like nice. But what if I have to show some data which is not present in a certain table?
Here is my code:
## models.py ##
## This is my main class.
class Application(models.Model):
name = models.CharField(max_length=100)
category = TreeForeignKey('Category', blank=False, null=False, verbose_name="name")
....
class Meta:
ordering = ('category__tree_id', 'category__lft', 'name')
## This is my category class.
class Category(MPTTModel):
name = models.CharField(max_length=50, unique = True)
parent = TreeForeignKey('self', blank=True, null=True, related_name='children')
class MPTTMeta:
include_self = False
order_insertion_by = ['name',]
ordering = ['tree_id', 'lft']
## This function returns list that I need to show in admin interface. As you can see I have to show name of every object which belongs to category.
def get_trailer(self):
application = Application()
apps_list = [application.__unicode__() for application in Application.objects.filter(category=self.id)]
logging.error("This is apps_list from get_trailer!")
logging.error(apps_list)
return apps_list
## Registering Category model as MPTT.
mptt.register(Category, order_insertion_by=['name'])
Here we got code of admin interface:
## admin.py ##
## This is class for show Application.
class ApplicationAdmin(admin.ModelAdmin):
list_display = ('name', 'category')
list_filter = ('category',)
ordering = ('category__lft',)
## This is class for show Category.
class CategoryAdmin(tree_editor.TreeEditor):
list_display = ('name', 'id',)
list_filter = ('parent',)
ordering = ('category__lft',)
Ok. Here we get all categories in tree-like format. When we click in any category we see just its name and parent. Look at this screenshot:
So, how to show this list through django and feincms? I don't want to create new keys in tables to do it.