radiac / nanodjango

Full Django in a single file - views, models, API ,with async support. Automatically convert it to a full project.
573 stars 25 forks source link

django view has unexpected keywords #38

Closed koaning closed 1 month ago

koaning commented 1 month ago

I tried running this example, which I copied from the docs here.

from nanodjango import Django

app = Django(DEBUG=True)

@app.route("/articles/<int:year>/<int:month>/<slug:slug>/")
def article_detail(request, *args, **kwargs):
    print(args)
    print(kwargs)
    return ""

However, this returns an error.

Internal Server Error: /articles/2002/12/this/
Traceback (most recent call last):
  File "/Users/vincent/Development/mktestdocs/.venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/Users/vincent/Development/mktestdocs/.venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
TypeError: string_view.<locals>.django_view() got an unexpected keyword argument 'year'

It feels like it might be an internal thing? Figured that I might report it.

koaning commented 1 month ago

Oh, and it is on this version: nanodjango==0.9.1

geoffbeier commented 1 month ago

I'm running into the same thing. I just forked and applied Pull Request #31. That both applies cleanly and fixes the problem.

radiac commented 1 month ago

Thanks for reporting this - it should be fixed by #31 in release 0.9.2 later today