Missing 1 required positional argument

Sadly. I’m defeated.

This e.g. code with furniture relates to a multi-row link rather than a single row link (I’m just looking for a single row). My ignorance is even more basic than translating this code e:g: on furniture type suggests.

I have two tables
Table one: called mood_journal
with three columns
mood_entry (text col for recording things that affect my mood e.g learning anvil)
mood_types (single col row linked to table two that lists mood_types)
mood_numbers (number col of nonsense numbers that I can use to plot graphs with)

Table two: mood_types
mood_types (text column with ‘happy’ ‘sad’ ‘neutral’ ‘desperate’)

This is my server code - which I have tried to adapt from the furniture type


@anvil.server.callable
def get_mood_type_count(mood_typename):
  type_row = app_tables.mood_types.get(mood_types=mood_typename)
  all_entries_of_mood_type = app_tables.mood_journal.search(mood_types=[type_row])
  count_of_journal_entries_of_mood_type = len(all_entries_of_mood_type)  
  return count_of_journal_entries_of_mood_type

This is my client code:


#     #plot graph for count of mood type 
    mood_counts = anvil.server.call('get_mood_type_count')
    self.plot_mood_counts.data = go.Bar(
    y = [k['mood_types'] for k in mood_counts]),

I’m getting this error:


TypeError: get_mood_type_count() missing 1 required positional argument: 'mood_typename'
at Form1, line 37

But I’m only trying to plot the ‘count’ of mood_types on y axis.

Any help gratefully received.

The app is here:

You are missing the argument called mood_typename in the server function. This is what the error is referring to.

So,

anvil.server.call('get_mood_type_count', "happy")

1 Like

D’oh! Thank you so much @alcampopiano

I was trying lots of combinations. I thought the only way of adding an argument to a func was like this:

get_mood_type(‘happy’)

Thank you