3

I've been over this for too many hours now and I cannot see anymore what I'm doing wrong:

url(r'^baz/([a-z0-9]+)/([a-z0-9]+)/[0-9]/$', 'foobar.views.baz')

def baz(request, xxx, yyy, zzz):
    pass

And this is the actual URL being requested:

http://localhost:8000/baz/75ca0f5bf13d67895e23419c25f82e87f3f5f95f/f733dbf686cd51f911e533d5a351f81394c9db5c/0/

Django keeps throwing this error at me:

baz() takes exactly 4 arguments (3 given)

What am I doing wrong?

1 Answer 1

6

You're missing the last block of parens in your regular expression.

url(r'^baz/([a-z0-9]+)/([a-z0-9]+)/([0-9])/$', 'foobar.views.baz')

With the parens Python will capture the [0-9] as a group and now you'll get all 3 parameters (+ the self) instead of 2.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Matthias! I actually had the parens in some earlier rev of that file!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.