News Aggregator tutorial "anvil not defined" NameError

I am currently experiencing this issue on the news aggregator tutorial. When I try to call the add_article server function from the client side.

Welcome to the forum!

I’m not able to replicate this error with a fresh clone of the final News Aggregator tutorial app:Anvil | Login

So in order to receive help, you may need to provide more details about what specifically you have done.

This is the server module:

import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
import anvil.server
from datetime import datetime

This is a server module. It runs on the Anvil server,

rather than in the user’s browser.

1 Like

Those lines run without error for me just now in a server module. Which line of code is triggering the error you are seeing? import anvil.tables as tables?

Please provide a clone link for your app.

Line 29 of the Homepage client code, the:

anvil.server.call(ā€˜add_article’, new_article)

This is the link:

https://anvil.works/build#clone:ROYTVHVFNOXBWUPS=CQQL7PG656EO4JIADJ3X62B2

Kind Regards,

You are missing an import in that client module :

import anvil.server

Gets created automatically, I think you must have accidentally deleted it?

1 Like

Thank you so much, that worked. I don’t see how I could have deleted it but you never know, that must be it.

Kind Regards,

2 Likes

It’s helpful if you click ā€œSolutionā€ under david.wylie’s post.

By the way, that import would not be created automatically if you have unchecked Auto import services in your settings.

1 Like

I didn’t know that was an option. I knew someone had asked for it, but I must have missed the announcement. Sneaky Updates by any chance?

Yep, was a sneaky one, I think: Sneaky Anvil Updates - #48 by hugetim

1 Like

Deffo missed that one, cheers!

I was about to complain it was in an unintuative place, but anywhere else would make it per app I suppose, and that’s likely a system wide setting.

1 Like