Module myapp.navigation has no attribute go_home

Hi,

Ive been tidying up my navigation so used the talkpython course naviation module to set up a separate navigation module

Initially when I did it using from navigation import navigation, I got the no module error, but then I changed it to the autocomplete suggestion from .. import navigation it now appears to recognize the module, but I am getting this error

AttributeError: module 'travevo_design.navigation' has no attribute 'go_home'

  • at HomeForm, line 32

Line 32 is this navigation.go_home() but it does it on all of the nav links.

On the navigation module, I have this, so it is there, as are all the other links??? Any ideas?

def go_home():
    set_active_nav('home')
    set_title("")
    form = get_form()
    form.load_component(HomeDetailsComponent())

I did a print(navigation) and got this, so it seems it is recognising it??? I’m lost on this.

<module 'travevo_design.navigation' from 'app/travevo_design/navigation.py'>

I solved it!

on the navigation module the def function start must not be indented at all.

home

So, on the talk python Anvil course, to get the navigation working you have to

  1. On your main form, call it as ..import navigation
  2. Make sure your functions on navigation have no indentation at all
  3. Ensure your form calls e.g from .HomeDetail import HomeDetail are done in navigation

I’ve seen a few posts about this issue and so this should help.

1 Like