In Django:
class Poll(models.Model):
question = models.CharField(max_length=200)
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()
p = Poll(question="What's up?")
p = Poll.objects.get(pk=1)
p.choice_set.create(choice='Not much', votes=0)
in web2py:
db.define_table('poll',SQLField('question',length=200))
db.define_table('choice',
SQLField('poll',db.poll),
SQLField('choice',length=200),
SQLField('votes','integer',default=0))
poll_id=db.poll.insert(question="What's up?")
poll=db(db.poll.id==poll_id).select()[0] ### poll.id == poll_id
db.choice.insert(poll=poll_id,choice='Not much',votes=0)
Hope this helps.
Massimo
On Nov 1, 10:08 pm, kev <[EMAIL PROTECTED]> wrote:
> Hello,
> I am checking out web2py after doing a little bit of django and i was
> wondering how you could do the following line in web2py:
>
> p = Poll.objects.get(pk=1)
> p.choice_set.create(choice='Not much', votes=0)
>
> What i need to know is how to go from poll to choice like django
> does.
>
> Thanks.
> Kev
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---