[Django]-Django occasionally throwing a NoReverseMatch

0👍

Turns out that the regex I was using while running the tests was slightly different to the one I posted in the question – I hadn’t reloaded my instance, and it was using the old regex I had been using: (?P<code>[\w:-_]+). The correct regex is (?P<code>[\w:-]+) – the :-_ makes the regex match the range from : to _ but doesn’t include the hyphen itself. The correct regex has they hyphen at the end of the set, so it is treated just as a hyphen character. Since the \w includes an underscore, the underscore is not necessary, but (?P<code>[\w:_-]+) would also be a correct regex.

Thanks to @fasouto for pointing me in the right direction!

-1👍

The output produces _ characters too.

👤rojoca

Leave a comment