Django view function not being called <p>Ths is the function in question. The problem is that it does not seem to do be called. User can download any files on the server, regardless of whether <code>pk</code> matches <code>request.user.id</code> or not.</p> <pre><code>def permit(request, pk): # First I sanitize system_path from request, then... if int(request.user.id) == int(pk) and int(request.user.id) &gt;= 1: sendfile(request, system_path) else: return render_to_response('forbidden.html') return HttpResponseRedirect('/notendur/list') </code></pre> <p>As you can see, it takes <code>pk</code> and compares it to <code>request.user.id</code>, and serves the file if that is the case.</p> <p>Then the relevant bits of <code>urls.py</code></p> <pre><code>urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), #upload urls (r'^notendur/', include('notendur.urls')), #This needs to be changed to welcome.html (r'^$', RedirectView.as_view(url='/notendur/list/')), # Just for ease of use. #security url(r'^media/uploads/(?P&lt;pk&gt;[^/]+)', 'notendur.views.permit'), url(r'^media', 'notendur.views.permit'), ) </code></pre> <p>This error sort of came out of the blue. I hadn't edited anything pertaining to this as far as I am aware.</p> <p>I know the function is not being called because I commented out the <code>sendfile()</code> and put <code>render_to_response('forbidden.html')</code> instead. Did not have any effect; user could still download file unexamined.</p>