Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialjun cheng wong
17,021 PointsValueError: 'name' may not contain a dot '.' character.
I don't understand what this means
raise ValueError("'name' may not contain a dot '.' character.") ValueError: 'name' may not contain a dot '.' character.
Some of my codes which I think might have caused the error are below:
api.add_resource(
CourseList,
'/api/v1/courses', # URI
endpoint = 'courses' # what we are going to call this end point
)
2 Answers
Chris Freeman
Treehouse Moderator 68,457 PointsHey jun cheng wong, according to the flask class Blueprint src code, line 194, checks if the Blueprint is initialized with a name
that contains a dot (’.’). More of your code is needed to see why name is set with a dot.
Post back if you need more help. Good luck!!!
Iris Avalon
14,477 PointsAdding this comment in case anyone else is having this issue:
The line causing problem in the above snippet is:
courses_api = Blueprint('resources.courses', __name__)
The first argument in the Blueprint constructor cannot have a dot character in it. Looking at the flask documentation for the Blueprint class, the first positional argument in the constructor is prepended to the endpoint name, that's all:
name (str) – The name of the blueprint. Will be prepended to each endpoint name.
So you can change 'resources.courses'
to something like just 'course'
and the app should build just fine
Rafael Gomes
6,963 Pointsthank you, changing 'resources.courses'
to just 'courses'
worked for me
jun cheng wong
17,021 Pointsjun cheng wong
17,021 PointsYeah, I think the main problem is that there is a dot inside 'resources.courses'. In my case, the 'courses' file is under the folder named "resources". I don't know how to fix it, appreciate if you can help