What I’m trying to do:
Trying to create two different views for two different types of users in my app. I printed both variables and its exactly what I expected. The email string is a text of my email, and result is True. Yet I still get the error. Maybe I am missing something?
anvil.google.auth.login()
email_addr = anvil.google.auth.get_user_email()
print(email_addr)
self.users_email.text = email_addr
user = app_tables.users.get(email=self.users_email.text)
client_type = user['client_type']
print(client_type)
if client_type is True:
open_form('Login.Body_Shop_Page')
else:
open_form('Login.Service_Provider_Page')
What I’ve tried and what’s not working:
Error code
anvil.tables.TableError: Column 'email' can only be searched with a string (not a Row from 'Users' table) in table 'Users'
Learn more about Data tables
<running on the server>
called from Login.Body_Shop_Page, line 18
called from Login, line 27
What does the print
print?
Print the email address text which equate to my email. Client_type is a true/false Boolean. The result is True.
As a sanity check, I’d try print(type(email_addr))
When I create a simple test app that uses the same code as you have, it works fine. Can you create a minimal clone that demonstrates the issue so we have something to play with?
That clone doesn’t give me the error you originally posted about.
1 Like
Pretty strange. That is the app I’m building. Did it give any error? I cloned it directly from the app. 
anvil.google.auth.login()
seems to be the culprit: It doesn’t actually log you in with the User’s table or using the User’s service. You’d want to setup google-only login in the User service and use this line: anvil.users.login_with_form()["email"]
I did that here:
I also allowed signups since I wasn’t a user yet, you can uncheck that if you want.
OR
If you really want to use the google login, you’ll have to manually add the users when they login to the Users table.
I think I found out what could be causing the issue, but I am not sure what I am doing wrong. When its checked boxed, aka True, it gives that error. When it’s not, it lets user’s login to and view service provider’s page.
if client_type is True:
open_form("Login.Body_Shop_Page")
else:
open_form("Login.Service_Provider_Page")
I just checked that other code path and made the same fix as my last post, and it’s the same thing I said above, you need to either use the built in User login system or add your custom created users to the Users table yourself.
1 Like