KeyError at /sss/edit/ 'pk'
<p>Hello I get this error:</p>
<pre><code>KeyError at /sss/edit/
'pk'
</code></pre>
<p>I know <code>KeyError</code> mean there's no key in a dict but I don't understand why it's giving me this error here.</p>
<p>Here's my code:</p>
<pre><code>class PostUpdateView(UpdateView):
     model = Post
     form_class = PostForm
     template_name = 'main/edit.html'

     def form_valid(self, form):
            self.object = form.save(commit=False)
            # Any manual settings go here
            self.object.save()
            return HttpResponseRedirect(self.object.get_absolute_url())

     @method_decorator(login_required)
     def dispatch(self, request, *args, **kwargs):
        post = Post.objects.get(pk=kwargs['pk'])
        if request.user.has_perm('main.change_post') and post.created_by == request.user:
            return super(PostUpdateView, self).dispatch(request, *args, **kwargs)
        else:
            return http.HttpForbidden()
</code></pre>
<p>I get error from <code>post=Post.objects.get(pk=kwargs['pk'])</code></p>
<p>I have this model as well</p>
<pre><code>class Post(models.Model):
    pub_date = models.DateTimeField(auto_now_add = True)
</code></pre>