Google AppEngine: obsługa formularzy „powtórzona” StructuredProperty
Jak mam pracowaćndb.StructuredProperty (repeat = True) właściwości, jeśli chodzi o projektowanie ich formularzy i programów obsługi? Rozważmy następujący przykład:
Mam 3 ndb.Model rodzaje:SkilledPerson, jegoEdukacjai jego (praca)Doświadczenie. Dwa ostatnie to typy StructuredProperty SkilledPerson.
class SkilledPerson(ndb.Model):
name = ndb.StringProperty()
birth = ndb.DateProperty()
education = ndb.StructuredProperty(Education, repeated = True)
experience = ndb.StructuredProperty(Experience, repeated = True)
class Education(ndb.Model):
institution = ndb.StringProperty()
certification = ndb.StringProperty()
start = ndb.DateProperty()
finish = ndb.DateProperty()
class Experience(ndb.Model):
job_title = ndb.StringProperty()
workplace = ndb.StringProperty()
start = ndb.DateProperty()
finish = ndb.DateProperty()
Jak mógłbym utworzyć formularz dlaWykwalifikowana osoba jednostka? Wyświetlone zostaną proste pola, takie jakimię inarodziny (StringProperty i DateProperty). Dodatkowo musi wyświetlać „grupę” pól dlaEdukacja iDoświadczenie Właściwości StructuredProperty. Wyobrażam sobie, że formularz wygląda tak:
<form method="post">
<h2>Skilled Person Form</h2>
<label>Name<br>
<input type="text" name="name" value="{{name}}">
</label>
<label>Birth<br>
<input type="date" name="birth" value="{{birth}}">
</label>
<!-- Education form goes here -->
<!-- and Experience form goes here -->
<input type="submit">
</form>
W jaki sposób mogę włączyć grupy pól do edukacji i doświadczenia w tym formularzu?
PrzykładEdukacja Formularz:
<form method="post">
<h2>Add Education</h2>
<label>Institution<br>
<input type="text" name="institution" value="{{institution}}">
</label>
<label>Certification<br>
<input type="text" name="certification" value="{{certification}}">
</label>
<label>Start<br>
<input type="date" name="start" value="{{start}}">
</label>
<label>Finish<br>
<input type="date" name="finish" value="{{finish}}">
</label>
<input type="submit">
</form>