I am brand new to Python, and Anvil, so please excuse me if this is a very dumb question, but Google and the documentation here hasn’t helped me.
I have an application where there are Projects, and inside each Project there are Interviews. I used the To-do list example to build a page where I can add new projects and display existing projects in a repeating panel. If I click on the Project_name I then open a new Form, and I have set up a new repeating panel where I want to display any interviews that belong to this Project.
Reading the notes I see I can do this to find a row:
# Get Jane Smith's row from the table
jane_smith = app_tables.people.get(Name="Jane Smith")
Which is great, but I can’t hard-code the Project_name into the server code - so how do I pass the current project name from the client side code to the server, look up the interviews that are linked to that project, and return those to the client to display in the repeating panel?
I’ve got this code at the moment:
class Project_Detail_Page(Project_Detail_PageTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
self.project = properties['Project']
self.project_name.text = self.project['project_name']
interviews = anvil.server.call('get_interviews', 'project_name')
self.repeating_panel_1.items = interviews
That’s on the client side, and I’m hoping to find the right rows on the server using this method:
@anvil.server.callable
def get_interviews(my_project):
this_project = app_tables.projects.search(project_name='my_project')
return app_tables.interviews.search(Project="this_project")
I have hacked around with the above get_interviews method until it’s ended up as this ugly mess, but I have no idea how I’m supposed to search the interviews table to find only rows that belong to the right project, nor how I can send the right details about the project from the client side to the server in the first place.
Can anyone help? This strikes me as something that’s incredibly basic functionality, but whatever I’m searching for is not throwing up useful answers.
FYI, if it helps, the error I get from this current code is:
anvil.tables.TableError: Column 'Project' can only be searched with a Row from 'Projects' table (not a string) in table 'Interviews'