this is model x.py:
# coding: utf8
db.define_table('dept',
Field('name',unique=True,label='Department Name'))
db.define_table('course',
Field('dept_id','reference dept'),
Field('name',unique=True,label='Course Name'))
this is is controller x.py:
# create a new department:
def create_dept():
form = SQLFORM(db.dept).process(next=URL('show_dept'))
return dict(form=form)
# list all departments
def show_dept():
rows = db().select(db.dept.ALL)
return dict(rows=rows)
# create new course:
def create_course():
form = SQLFORM(db.course).process(next=URL('show_all_course'))
return dict(form=form)
# list all courses
def show_all_course():
rows = db().select(db.course.ALL)
return dict(rows=rows)
now this is view of x/create_course:
{{extend 'layout.html'}}
<h1>This is the x/create_course.html template</h1>
<h2>
Enter the name of the course you want to create
</h2>
{{=form}}
now my question is -> when I create a new course I have to fill in the the
dept(department) id myself how can I make it a dropdown where the the
department names are shown and I select a department name and enter the new
course name and press submit and it creates a new course in that department.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.