unexpected kawrgs ,TypeError at /courses/course/1/1/
<p>I'm getting type error for the pk.
Something like:</p>

<p>step_detail() got an unexpected keyword argument 'pk' for the second one in /courses/course/1/1, where as it has been taken care in the following method of step_detail. What am I doing wrong? </p>

<p>views.py</p>

<pre><code>from django.shortcuts import render
from django.shortcuts import get_object_or_404
from .models import Course, Step


def course_list(request):
    courses = Course.objects.all()
    return render(request, 'courses/course_list.html', {'courses': courses})


def course_detail(request, pk):
    # course=Course.objects.get(pk=pk)
    course = get_object_or_404(Course, pk=pk)
    return render(request, 'courses/course_detail.html', {'course': course})


def step_detail(request, course_pk, step_pk):
    step = get_object_or_404(Step, course_id=course_pk, pk=step_pk)
    return render(request, 'courses/step_detail.html', {'step': step})
</code></pre>

<p>And the url.py:</p>

<pre><code>from django.conf.urls import url
from . import views

urlpatterns= [
    url(r'^$', views.course_list),
    url(r'(?P&lt;course_pk&gt;\d+)/(?P&lt;pk&gt;\d+)/$', views.step_detail),
    url(r'(?P&lt;pk&gt;\d+)/$', views.course_detail),
]
</code></pre>

<p>You are using 2 different variable names:</p>

<ul>
<li><code>pk</code> in <code>urls.py</code></li>
<li><code>step_pk</code> in <code>views.py</code></li>
</ul>

<p>You should use the same name.</p>

python django