Pyramid: Views registered with `view_config` not being associated with routes

pyramid, python

Solution

You are naming the view, not the route in your @view_config decorator. You want:

@view_config(route_name='hello')
def hello(request):
    return Response("Hello, world!")

Problem

I'm declaring a route like this: ``` from my_package import views config.add_route("hello", "/hello") config.scan(views) ``` And in `my_package.views` I have the view: ``` from pyramid.view import view_config @view_config(name="hello") def hello(request): return Response("Hello, world!") ``` But route isn't being associated with the view. Specifically, checking routes in the debug toolbar shows that no view callable is associated with the `hello` route, and visiting `/hello` returns a 404. Changing the route definition to something like `config.add_route("hello", "/hello", views.hello)` works correctly. What am I doing wrong?

Original source