Sorry, the error should have read:
File "C:/web2py16/applications/lconfirm/controllers/dogs.py"
<http://127.0.0.1:8000/admin/default/edit/lconfirm/controllers/dogs.py>, line
27, in update_flea_count
db.dogs.update_or_insert(db.dogs.dog_name == row.dog_name,
AttributeError: 'Row' object has no attribute 'dog_name'
The code is as follows:
Model
db.define_table('dogs',
Field('dog_name','string'),
Field('flea_Count','integer'))
db.define_table('fleas',
Field('dog_name','string'),
Field('flea_name','string'))
Controller
def populate():
db.dogs.truncate()
db.fleas.truncate()
db.dogs.insert(dog_name='dagwood')
db.dogs.insert(dog_name='daisy')
db.fleas.insert(dog_name='daisy', flea_name='fatso')
db.fleas.insert(dog_name='dagwood', flea_name='felix')
db.fleas.insert(dog_name='dagwood', flea_name='fatso')
def update_flea_count():
query = db(db.fleas.id>0).select(db.fleas.dog_name,
db.fleas.flea_name.count(), orderby=db.fleas.dog_name,
groupby=db.fleas.dog_name)
for row in query:
db.dogs.update_or_insert(db.dogs.dog_name == row.dog_name,
dog_name = row.dog_name,
flea_count = row.fleas.flea_name.count)
form = SQLTABLE(query)
return dict(form=form)
def update_flea_count1():
query = db(db.fleas.id>0).select(db.fleas.dog_name,
db.fleas.flea_name.count(), orderby=db.fleas.dog_name,
groupby=db.fleas.dog_name)
form = SQLTABLE(query)
return dict(form=form)
Apologies for that.
(Its what happens at 1.30am when you suddenly discover that someone has
just rewritten beancount :))
--
---
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.