[Answered ]-Getting "AttributeError: 'str' object has no attribute 'regex'" in Django urls.reverse

2👍

I’m answering this to share knowledge as I didn’t see this particular root cause identified already.

The problem turned out to be that I should be using a keyword argument ‘args=args’ to pass in URL arguments, not a positional argument:

HttpResponseRedirect(reverse('changetracker:detail', args=args))

Using the positional argument (position 2) caused reverse to use that argument as the URL list and thus raise the AttributeError.

Leave a comment