Cannot pass data to DataTable

So I’m working on an Anvil project and have an issue. I am attempting to use Anvil to create a type of interactive quiz. I have coded an interactive quiz in Python with over 350,000 questions which I can access, but want to have a quiz that’s available to anyone online, and believe I could get one made with Anvil. My first step is to create a sample quiz, but I’m stuck on a step.
I am attempting to use the Feedback Form Tutorial as a template, which should work. It has place for a name, question, and answer.
When I do try and link it to this I get this error message…
“anvil.tables.TableError: Column ‘answer’ is a string - cannot set it to a simpleObject”
Any advice on what I could do to get the inputted answers to pull over to the Data Table?
Thanks!
-Taylor

Hello,

Are you able to show the lines of code that you are using to send data to the data table and let us know a bit about your data table setup? Something a bit more specific might help. For example, when you print the text you are trying to send back to the data base, what is the output?

A simple clone link may be helpful as well if you don’t mind sharing (click the :gear: icon to share).

Based on the error it seems like you are trying to pass an answer that is actual a dictionary or a list (or something else that could be stored in a column meant for simple objects).

Please see the docs here on column types of DataTables and make sure you are sending compatible types to their respective columns (strings go to text columns, numbers go to number columns, etc…)

You may have to delete one of the columns and remake it, and set it to hold text instead of a simple object.

2 Likes

Hi Campopianoa,

Thanks for the response! Here is the clone link…

https://anvil.works/build#clone:AMYHUW7SEMVAB2P4=YS6WTTIIZBUTU63OP6A2TTQW

Please advise if that doesn’t work, and if you want to take a look and see if you can help me out it would be much appreciated!

I’ll also take a look over the Data types and message you sent and see if I can get that to work myself.

Thanks so much once again!

-Taylor

you’ve missed .text from line 23

answer = self.text_area_1

should be

answer = self.text_area_1.text
4 Likes

A post was split to a new topic: Sharing data tables between apps