Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python

competent- fellow
competent- fellow
5,846 Points

"name 'render' is not defined"

I was able to import "utils". However, "render" still did not work.

for label, value in balances.items(): render("The label {} has a value of {}".format(label,value)) --> NameError: name 'render' is not defined

I could not find any documentation for utils' render function online.

Instead, I just used print() and that worked just fine. Perhaps this is a version issue?

3 Answers

Hi Craig, did you import render with from django.shortcuts import render?

competent- fellow
competent- fellow
5,846 Points

Hello Mat. No. I did so with either:

  • from utils import render (which returns an error) Or:
  • import utils (error only when I call render) I installed utils with Anaconda.

Right on. Use the import I mentioned, and you should be good to go!

competent- fellow
competent- fellow
5,846 Points

Hello Matt. Thanks for your advice. I am not sure django's render does the same thing. I get this error message:

TypeError: render() missing 1 required positional argument: 'template_name'

Apologies, I may have misunderstood what was happening. Could you link this to the challenge or video you are working with?