-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use underscore in route method names #456
Comments
It's because pynecone try to guess the actual route based on your method name. Can you try to add the keyword arg |
Tried. Still doesn't seem to work, unfortunately. |
Okay I reproduced the problem, there is indeed a bug if you put an underscore in the route name. Meanwhile, the following should work until the bug is resolved:
or
|
Thanks. Glad it wasn't just me! |
We automatically convert underscores to hyphens - so the route should be available at We should either document this better or we can change this logic if people like. |
I can confirm that I don't feel strongly that this has to be rendered with the underscore. This said, it might be easier to render it with the underscore instead of converting it to a hyphen all else being equal, because it will prevent people from getting confused and having to find an answer in the documentation. |
@picklelo Is there a reason why routes convert underscore to hyphens? I see the line of code in app.py line: 1032
Is there history behind this or is it just based on hyphens being more popular for routes than underscores? I personally go either way on this but to close this issue out we should either nix that line and let people run with underscores or we could put a warning on https://pynecone.io/docs/components/pages under "adding a page" that tells people of this behavior. |
Hi all, this behaviour was causing issues for me also and took a little while to understand what was happening, so thank you for this. I think it is more appropriate to change the logic. This conversion is applied to all routes, meaning the behaviour is particularly confusing where an explicit route is provided as there is no way to define a route with an underscore. e.g. |
This is resolved in #1713 - if you use |
Describe the bug
I get an error when using a route method name like
def sign_up()
versusdef signup()
. While a minor annoyance, this conflicts with common Python code style.To Reproduce
Steps to reproduce the behavior:
def sign_up()
and add it to your routesExpected behavior
You should be able to use underscores in route method names.
Screenshots
Not necessary.
Specifics (please complete the following information):
Additional context
I don't think any additional context is necessary. But if I'm doing something wrong, let me know.
The text was updated successfully, but these errors were encountered: