I am trying to import a client side module used for navigation and get this error.The module name is navigation.
ValueError: Attempted relative import beyond toplevel package at [navigation, line 6](javascript:void(0)) called from [Homeform, line 13](javascript:void(0))
The error is called from line 13 which is, from …import navigation
from …import navigation
class Homeform(HomeformTemplate):
def init(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
# Any code you write here will run when the form opens.
navigation.go_home()
Thanks in advance for any help
def Home_click(self, **event_args):
You will have to provide a clone link for that. It happens because every form needs different code for importing. Some requires two dots, some one and some three. Don’t know the logic behind it though.
The dots are indeed kinda inscrutable, I would just let the auto complete guide your import. If that fails try 0-3 dots before the from statement until it works
I am trying to import navigation module into homeform but get an import error no module named navigation
I have changed the dots from 0 to 3 tosee if that solves the error but no joy.
There is a client module navigation
@waynedavidstokes Did you figure out how to solve the import problem?
The accepted solution does not really answer the original question in this thread.
Thanks!
I have found the solution to my problem to another thread.
I assume the original poster was also following the anvil tutorial from TalkPython and got stuck on the issue that one of the imports was not working as it was a circular import problem.
I am leaving this comment and this link here Error while importing server module should anyone land on this thread via Google Search. (like I did originally)
I am following the TalkPython Tutorial but following what you say on this post doesn’t really solve my problem. Please can you tell me exactly what you did? I am completely blocked with: <ValueError: Attempted relative import beyond toplevel package< !
Please reply as soon as possible. I really want to move on.
You have too many dots in your import. Let the autocomplete help you work out what the import should be, don’t just type in what the tutorial shows you for the import.