1

I followed the guide here to add versioning to our API. This is what the urls.py looks like:

from django.conf.urls import url
from django.contrib import admin
from django.urls import path

from api import views

urlpatterns = [    url(
        r'^(?P<version>(v1|v2))/foo/bar',
        views.foo_bar,
    ),
]

However, when I hit my API with the URL http://localhost:5555/v1/foo/bar I get an error:

TypeError at /v1/foo/bar
foo_bar() got an unexpected keyword argument 'version'
ritratt
  • 1,703
  • 4
  • 25
  • 45

1 Answers1

3

Most likely your foo_bar view does not accept the argument version.

It needs to be defined as:

def foo_bar(request, version):
    ...
andreihondrari
  • 5,743
  • 5
  • 30
  • 59