[Django]-Django preview, TypeError: 'str' object is not callable

8👍

✅

The signature for the url function within a urlconf is like this:

def url(regex, view, kwargs=None, name=None, prefix='')

You are using positional parameters only, but are passing only regex, view and name. So Python thinks your third parameter is the kwargs dictionary, not the name.

Instead, do this:

url(r'^admin/diligencias/diligencia/(?P<object_id>\d+)/preview/$', name='preview'),

to pass the name as a kwarg so that Python recognises it properly.

2👍

I suspect your view isn’t a function. Make sure the argument in your urls.py is a function that takes one parameter. Like :

import default

url(r'^s(?:ite)?/search$', default.search, name="search"),

And then you have in default.py

def search(request) :
    # do stuff

Leave a comment