I am a totally stupid beginner of coding, and really confused by lots of
posts that explain how to create a drop-down selection.
Here is my question:
3 tables: nations, shops, brands
the relationships between these tables are:
a country has multiple shops;
a shop has multiple brands;
some of brands are in different shops, for example, brand A is in both shop
X and shop Y.
My object is that user can choose shops in a range, select country to see
shops belong to this country, select brand to see shops have this brand,
and select all to see all shops.
So I have 3 tables: countries, shops and brands. In MVC model, these tables
are defined in models/db.py, and I am able to input information in DB admin
panel.
db.define_table('countries',
Field('name'),
format = '%(name)s'
)
db.define_table('shops',
Field('name'),
Field('country_id', 'reference countries'),
format = '%(name)s'
)
db.define_table('brands',
Field('name'),
Field('shop_id', 'reference shops'),
Field('story', 'text'),
Field('address', 'text'),
Field('opening hours', 'date'),
format = '%(namecn)s'
)
But then, how to write in controllers/default.py, and how to create
views/default/selection.html? I want selection looks like it has 2 dropdown
lists, users choose a country from one of them and submit, or choose brand
from another of them and submit. And a link named click to see all shops.
Once users make action, then to get a shop list in different range (belong
to a country, or have a selected brand, or all of them), and shop list
shows shop links. I am afraid it is not clear, see below picture.
selection.html
-------------------------------------------------
_______________ _______
| select a country | | submit |
--------------------------- -------------
_______________ _______
| select a brand | | submit |
--------------------------- -------------
*See all shops*
---------------------------------------------------
if select a country or brand and click submit, or click *See all shops*
---------------------------------------------------
shops in A country (or shops has brand B, or ALL shops)
*shop1*
*shop2*
*shop3*
*shop4*
*.......*
*.......*
*shopn*
---------------------------------------------------
once click one of shop's link, users go to final page:
---------------------------------------------------
ShopX
Story: bala bala
address: bala bala
opening hours: bala bala
all brands in this shop:
brand1
brand2
brand3
......
......
brandn
---------------------------------------------------
I read several cases in manual, forum, QA webpages but still not success
because I am too stupid that can only understand the good sample in manual
(to create a photo blog, or wiki). Can somebody give me clear codes (in
controller and view) for this sample. If there is already a sample similar
to my one, just give me a link please. Thanks a lot !!!!!!!
--
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.