Woohoo it's now working! Thank you Anthony!!! 2 questions:
1. When I have listing.title.requires = [IS_IN_DB(db, db.title.id, '%(name)s')] as a list (which is how I want it, it doesn't seem to let me register, it still expects an int, how can I make it expect a string that's equal to an id? Cause obviously people can't just guess the id of their title hahaha 2. I'm running a little test on index to figure out how to display the first names that have the reference id '36' using this code: def index(): painters = db(db.listing.title == 36).select() items = [] for painter in painters: items.append(DIV(A(painter.first_name, _href=URL('index')))) return dict(items=items) But it's just displaying this on the index page: [<gluon.html.DIV object at 0x9982a50>, <gluon.html.DIV object at 0x9982b30>] Which is good in a way because it's picking up the 2 points in memory that I have linked to 'Painter' but it's not displaying them right? I think it's to do with my returning of a dictionary, but I'm not sure how to fix it, or even find an answer to this. P.S Are you the Anthony that was helping me on Stack Overflow too? If so thanks, your help is awesome, hopefully I can pay it back one day :) On Aug 14, 9:56 pm, Anthony <abasta...@gmail.com> wrote: > Is "Plumber" being entered in the 'title' field of the user table? If so, > that field is expecting an integer because it is a reference to the 'id' > field of the 'title' table (which is an integer field). > > listing.title.requires = [IS_IN_DB(db, db.title.name)] > > Your validator, on the other hand, is requiring a string that is one of the > names stored in db.title.name. So, your form/validator wants a string, but > the database wants an integer. You can change your validator to: > > listing.title.requires = [IS_IN_DB(db, db.title.id, '%(name)s')] > > Note, because the validator is inside a list, it will not display the > typical dropdown for an IS_IN_DB validator. If you want the dropdown, take > it out of the list. Also, if you simply add format='%(name)s' to your > 'title' table definition, you don't have to bother specifying the validator > for the listing.title field at all because the default validator will be the > above IS_IN_DB validator anyway. > Seehttp://web2py.com/book/default/chapter/07#Database-Validatorsandhttp://web2py.com/book/default/chapter/06#Record-Representation. > > Anthony > > > > > > > > > > On Sunday, August 14, 2011 5:39:27 AM UTC-4, Jarrod Cugley wrote: > > Hi guys this is my first post so just let me know if I'm doing > > anything wrong :) (Massimo recommended I ask questions here about > > web2py rather than on Stack Overflow) > > > As the title says: I keep getting the error: invalid literal for int() > > with base 10: 'Plumber' > > I've done searching and it seems to be a common error, but I can't > > figure out how to fix it from the answers I've already read, here is > > my code (that I think is the needed code to solve the error): > > > ___DB.PY___: (model) > > > db.define_table('title', > > Field('name'), > > ) > > > db.define_table(auth.settings.table_user_name, > > Field('first_name'), > > Field('last_name'), > > Field('email'), > > Field('password','password', length=512, > > readable=False, label='Password'), > > Field('title', db.title), > > Field('bio','text'), > > Field('phone'), > > Field('website'), > > Field('address'), > > Field('registration_key', length=512, > > writable=False, readable=False, default=''), > > > > > > > > > Field('reset_password_key', length=512, > > writable=False, readable=False, default=''), > > Field('registration_id', length=512, > > writable=False, readable=False, default=''), > > ) > > > listing = db[auth.settings.table_user_name] > > listing.title.requires = [ > > IS_IN_DB(db, db.title.name)] > > > ___DEFAULT.PY___: (controller) > > > def index(): > > painters = db(db.listing.title == 23).select() > > items = [] > > for painter in painters: > > items.append(A(painter.first_name, _href=URL('index'))) > > return dict(items=items) > > > In my view I just have {{=items}} > > > On top of this I can't create new users from the registration form or > > the appadmin, because it brings up the same error when I submit both > > registration forms. > > > I'm so confused (because I'm an obvious newbie :P) any help would be > > greatly appreciated! :)