候補モデルがあります
class Candidate(ndb.Model):
name = ndb.StringProperty()
phone = ndb.StringProperty()
location_name = ndb.StringProperty()
state = ndb.KeyProperty(kind=Setting)
提出状態と呼ばれるモデル
class SubmissionState(ndb.Model):
name = ndb.StringProperty(required=True)
description = ndb.TextProperty()
モデル設定は、ユーザーが選択したカテゴリに基づいて設定を処理するために使用されます。これはすべて正常に機能します。
ここにありviews.py
ます。post メソッドもありますが、ここで必要かどうかはわかりません。
class EditSubmission(webapp2.RedirectHandler):
def get(self):
candidateid = self.request.path.split('/')[-1]
candidate = Candidate._get_by_id(int(candidateid))
template_values = {'candidate': candidate, }
path = os.path.join(os.path.dirname(__file__), '../templates/edit_submission.html')
self.response.write(template.render(path, template_values))
テンプレート部分は次のとおりです。
<tr>
<th><label for="id_state">Submission State:</label></th>
<td><input id="id_state" type="text" name="state" value="{{ candidate.state.name }}"/></td>
</tr>
とすれば{{ candidate.state }}
キーと全フィールドを取得するのですが、なぜか名前だけ取得できません。どうすればいいですか?
ありがとう。