# Model
db.define_table('livestock_animals',
Field('eartag_number'),
Field('retagged_number'),
Field('dob', 'date'),
Field('breed', db.breed),
Field('sex', db.sex),
Field('dam'),
Field('sire'),
Field('herd', db.livestock_herd),
Field('proprietor', db.ownership),
auth.signature)
# Controller
@auth.requires_login()
def livestock_animals():
form = crud.create(db.livestock_animals, request.args(0))
return dict(form=form)
@auth.requires_login()
def livestock():
db.livestock_animals.proprietor.default = me
crud.settings.formstyle = 'table2cols'
form = crud.create(db.livestock_animals)
livestock =
db(db.livestock_animals.created_by==auth.user_id).select(orderby=~db.livestock_animals.created_on,limitby=(0,100))
return locals()
#View - default/livestock
{{extend 'layout.html'}}
{{=form}}
{{for animals in livestock:}}
<div>
{{=(livestock_animals.eartag_number)}}
{{=(livestock_animals.dob)}}
{{=(livestock_animals.breed)}}
{{=(livestock_animals.sex)}}
{{=(livestock_animals.dam)}}
{{=(livestock_animals.sire)}}
{{=(livestock_animals.herd)}}
{{=(livestock_animals.proprietor)}}
</div>
{{pass}}
Good day Guys,
The code above returns the following error;
<type 'exceptions.NameError'> name 'livestock_animals' is not defined
but I am not able to figure out why, can someone provide me with some
advise with respect to what I am doing wrong.
Kind regards,
Rafer
--
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.