Hello guys,
I'm struggling with a problem that's driving me crazy. The validator IS_NOT_IN_DB which I use for my object "tag" does not work for me.
# TAG
db.define_table('tag',
Field('name', requires=(IS_SLUG(), IS_LOWER(), IS_NOT_IN_DB(db, 'tag.name'))),
Field('is_public', 'boolean', default=False, readable=False, writable=False),
auth.signature,
common_filter = lambda query: db.tag.is_public == True)
db.tag.name.requires = IS_NOT_IN_DB(db, 'tag.name')
As you can see, there are two ways I made sure that no duplicates can be created, in the name field itself and outside of the table definition.
Registered user can suggest tags:
Although the tag "test" has already been submitted twice I could submit it a third time.
The function looks as follows:
What I already tried (without improvement):
- adding "unique=True" to the name field
- just using .process() without "onvalidation"
- "ignore_common_filters" on and off
- inside the "my_form_processing"-method I checked if the amount of db objects with the given name is > 0 , but i could not figure out how to stop the form from processing
Please let me know how I can fix that problem.
Thanks!
Jay