Hello everyone. I have this code that works. My class is a db.Model
one2many with a teacher, experience, and so on...

What I want is to call the class teacher with forms, but also intend
to include other classes, like a form from experience class and a form
from category. These classes are as foreign Key teacher.

I wonder how to derive classes for teachers

This is my main:

class CreateCvHandler(webapp.RequestHandler): def post(self): if
self.request.get('EscTeacher'): id =
int(self.request.get('EscTeacher'))
teacher=models.teacher.get(db.Key.from_path('Teacher', id)) else:
teacher= models.teacher() data = forms.TeacherForm(data =
self.request.POST) if data.is_valid(): userList= models.Account.all()
userList.filter('user =', users.get_current_user()) for user in
userList: teacher.user=user.key()
teacher.unity=self.request.get('unity')
teacher.category=self.request.get('category')
teacher.regime=self.request.get('regime') teacher.put()
self.redirect('/academy') else: self.redirect('/createCv'

Can anyone send me a snippet

Thanks

On 16 Ago, 14:50, xerife <[email protected]> wrote:
> Sorry, but I did not understand. I got the forms (db.Model), in the
> example i´ve included only the class Teacher and the respective form.
> But i have 5 more models/classes/forms
> My code is fine with just one model/form.
> My question is how to integrate into my main, forms of different
> classes.
> Do I have teacher.put (), Experience.put (), and so on?
> or is there other way?
>
> If someone showed me a real example of implementation, i would
> appreciate.
>
> On 16 Ago, 14:30, djidjadji <[email protected]> wrote:
>
>
>
> > You have to use the newforms.Form class yourself and construct the
> > needed Fields.
>
> > from django import newforms as forms
> > class FiveClassForm(forms.Form):
> >     someNr   = forms.IntegerField(min_value=1)
> >     someStr  = 
> > forms.CharField(max_length=40,widget=forms.TextInput(attrs={'size':'40'}))
>
> > When processing the POST, create a dictionary with Key,Value pairs and
> > pass this to the constructor
>
> > def post(self):
> >     formdict = .......
> >     fiveForm = FiveClassForm(formdict)
> >     if fiveForm.is_valid():
> >         sNr = fiveForm.clean_data['someNr']
>
> > 2010/8/16 xerife <[email protected]>:
>
> > > I apologize if I was not specific. My program will help teachers meet
> > > their curriculum vitae. The sheet will be printed in pdf format. This
> > > single sheet has several forms that are of different classes. So far
> > > only seen examples of forms with only one class and I'm having trouble
> > > getting the form with more than one class, write on DB and display the
> > > data.
> > > In my particular case, the sheet with the forms would have five
> > > classes.
>
> > > On 15 Ago, 19:16, xerife <[email protected]> wrote:
> > >> I have a model with 5 entities and intend to create a form (on the
> > >> same page) but do not know how to integrate more than one form.
>
> > >> In my main, i can play very well with the forms and write to database,
> > >> but I need to put more fields on the page.
> > >> These fields are of different models.
>
> > >> My models:
> > >> Teacher, Account(ReferenceProperty), Experience (ReferenceProperty),
> > >> ServiceDistribution(ReferenceProperty), Experience(ReferenceProperty)
>
> > >> My forms:
> > >> class TeacherForm(djangoforms.ModelForm):
> > >>     class Meta:
> > >>         model =models.Teacher
> > >>         exclude = ['user']
> > >> and the same for other models
>
> > >> My Main:
> > >> class CreateCvHandler(webapp.RequestHandler):
> > >>     def post(self):
> > >>         if self.request.get('EscTeacher'):
> > >>             id = int(self.request.get('EscTeacher'))
> > >>             teacher=models.teacher.get(db.Key.from_path('Teacher',
> > >> id))
> > >>         else:
> > >>             teacher= models.teacher()
>
> > >>         data = forms.TeacherForm(data = self.request.POST)
> > >>         if data.is_valid():
>
> > >>             userList= models.Account.all()
> > >>             userList.filter('user =', users.get_current_user())
>
> > >>             for user in userList:
> > >>                 teacher.user=user.key()
> > >>             teacher.unity=self.request.get('unity')
> > >>             teacher.category=self.request.get('category')
> > >>             teacher.regime=self.request.get('regime')
>
> > >>             teacher.put()
> > >>             docExp.put()
> > >>             self.redirect('/academy')
> > >>         else:
> > >>             self.redirect('/createCv')
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Google App Engine" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to 
> > > [email protected].
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/google-appengine?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to