Hi, I have 2 issues I would appreciate help with:-
When I upload, I am trying to add(append to dict) different images, my code appends 4 images, but they are all the same? Only image 1 gets added 4 times.
When I try and delete one, using the unique id(uid), I get this error anvil.tables.TableError: Column 'UniqueID' can only be searched with a number (not a media) in table 'mystuff'
But I did a print statement on uid and it is a number???
Notice anything different between them? I guarantee you didn’t do print(uid) on the server, which is where the error was happening. Always do your diagnostic print statements as close to the line with the error as possible.
Thanks for the reply, its much appreciated. I’ve now solved the first error, I created two variables and then used those in the loop instead of the direct field reference.
But the second one I’m still stumped on. You are right I didnt do the print on the server. I tried creating a variable of sel.item[‘MyStuffImage’] and passing that to the server, I tried switching the order of the variables, which has stopped the number error.
Now I’m getting another error: anvil.tables.TableError: Cannot use a Media object as a search query
Will I need to add another column in mystuffimage in order to search on that table, the uid is from the mystuff table so I can access the correct row there?
Yes, you’ll need some way of uniquely identifying a row in that table. Your current two columns combined do uniquely identify a row, but you can’t use one of them in a search, so you’ll need another column that you can use in a search. A unique integer would work fine.
Seems you cant do much about it, so I’m thinking I will have to add another column on my images, and instead of deleting, it will change the status of the image to archived, then when I do my server query to get the images, I’ll have to add that extra line in. It seems a long way to go around the problem???
zaphod = app_tables.people.get(Name="Zaphod Beeblebrox")
ford_prefect = app_tables.people.get(Name="Ford Prefect")
zaphod["Friends"] = [r for r in zaphod['Friends'] if r != ford_prefect]
Look at what the ford_prefect variable contains. Not a single column value, but the entire row whose link should be removed.
I see, I’ve just changed it now, and it did delete the link… … and some more from records below it. well its 00:30 here now and I am very tired, so hopefully I can look at it with fresher eyes in the morning.
Have a great evening… and thanks again.
EDIT. Its working, dont know what happened last night, but I’ve done a few this morning and that hasn’t happened again.