How to use IS_NOT_IN_DB

33 views
Skip to first unread message

Morganti

unread,
Dec 4, 2017, 2:53:22 PM12/4/17
to web2py-users
Hi,

I am creating a form with SQLFORM.factory. I have a field 'username' and 

Field('username','string',requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db,'auth_user.username')]

and when try to use I am having the error:

<type 'exceptions.Exception'> Validation error, field:username <gluon.validators.IS_NOT_IN_DB object at 0x7ffaa4136310>


What's wrong?

Thanks
BR
André

Richard Vézina

unread,
Dec 4, 2017, 3:13:43 PM12/4/17
to web2py-users
I think you have to clone the field, in context of .factory

Richard

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Richard Vézina

unread,
Dec 4, 2017, 3:17:01 PM12/4/17
to web2py-users
Something like that : 

form_fields.append(db[request.args(0)][f].clone(requires=IS_EMPTY_OR(db[request.args(0)][f].requires)))

Richard
Reply all
Reply to author
Forward
0 new messages