2016-07-21 7 views
0

私は、管理者のプラグインのタイトルをその子供のタイトルに変更したいと思います。タイトルをit'sとして 私はそれをプラグインを確認したいが、真のショーの場合、子供、タイトルを持っていますdjango-cms adminで使用するための子プラグインからタイトルを取得するには?

私はこれまで来た:

class ParentClass(CMSPlugin): 

def __unicode__(self): 
    inner_content = "" 
    if ... >= 1: 
     for child in children: 
      inner_content += child.title 
    else: 
     inner_content = "empty" 
    return unicode(inner_content) 

class ChildClass(CMSPlugin): 
title = "X" 

はこの可能のようなものですか?

答えて

0

どのようにこのようなものについて:

class ParentClass(CMSPlugin): 

    def __unicode__(self): 
     inner_content = '' 

     if self.child_plugin_instances is not None: 
      for child in self.child_plugin_instances: 
       inner_content += child.title 

     inner_content = inner_content or "empty" 
     return unicode(inner_content) 
+0

はありがとうございます。 'デフ__unicode __(自己): inner_content = [] をself.child_plugin_instancesがNoneでない場合:self.child_plugin_instancesに子供のため : inner_content.append(子私はそれを変更し、右の出力を得たことを確認するために、 .__ unicode __()) inner_content = '、' .join(inner_content)または「空」 return str(inner_content) ' –

関連する問題