Alright, it's awesomely works now. :) (just fyi the r.content returns this and not the id of newly created record.:) >>> r.content 'errorsid'
Thanks again . On Monday, February 3, 2014 2:31:00 AM UTC+2, Anthony wrote: > > As I recall, you have more than one reference field, but looks like you > are only converting one of them. You'll need to do some debugging to figure > out exactly which field or fields are generating errors, and then make the > appropriate corrections. > > On Sunday, February 2, 2014 4:21:37 PM UTC-5, Avi A wrote: >> >> getting this error: >> >> ValueError: invalid literal for long() with base 10: 'ergergrg' >> >> >> t = db.t_tests_results >> def POST(**post_params): >> if db(db.auth_user.api_key == post_params['api_key']).count(): >> #post_params['f_test'] = db(db.t_tests.f_test_name == >> # post_params['f_test']).select( >> db.t_tests.id).first().id >> #post_params['f_project'] = db(db.t_projects.f_project_name == >> # post_params['f_project']).select( >> db.t_projects.id).first().id >> post_params['f_platform'] = db(db.t_types.f_platform_name == >> post_params['f_platform']).select( >> db.t_types.id).first().id >> #post_params['f_device'] = db(db.t_devices.f_device_name == >> # post_params['f_device']).select( >> db.t_devices.id).first().id >> >> return t.validate_and_insert(**t._filter_fields(post_params)) >> else: >> raise HTTP(400) >> return locals() >> >> >> On Saturday, February 1, 2014 11:24:02 PM UTC+2, Avi A wrote: >>> >>> Yes, that's what I want. >>> I'll give it a try , thanks. >>> >>> On Saturday, February 1, 2014 10:30:28 PM UTC+2, Anthony wrote: >>>> >>>> Without the ability to post data to reference fields it's a problem to >>>>> achieve it. just posting the reference data as strings won't allow me to >>>>> make these filters, unless I will insert them into tables after posting >>>>> to >>>>> the tests results table. (I think). >>>>> >>>> >>>> Keep in mind, a reference field references an entire record in another >>>> table, not just a particular string field in that table. In general, the >>>> referenced table may not even include a string field that contains unique >>>> values, so you couldn't reference a particular record simply by specifying >>>> a single string. >>>> >>>> I'm not sure I completely follow your data model, but for example, is >>>> the f_platform field a reference to the db.t_types table (which itself >>>> contains an f_platform_name field)? Is it the case that you want users to >>>> be able to specify an f_platform_name string and have that converted to >>>> the >>>> appropriate record ID of the t_types table so the ID can be stored in the >>>> f_platform field? If so, you just need to write the code to do that: >>>> >>>> post_params['f_platform'] = db(db.t_types.f_platform_name == >>>> post_params['f_platform']).select(db. >>>> t_types.id).first().id >>>> >>>> That will use the string value of f_platform to look up the record ID >>>> in db.t_types, and then change post_params['f_platform'] to that record >>>> ID. >>>> You could do something similar for any other fields that need to be looked >>>> up/converted. >>>> >>>> Anthony >>>> >>>> -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.