Duplicate URLs and url names

As documented, when you have two identical paths (or a path that matches multiple patterns) in your urlpatterns, Django will dispatch to the first one that matches.

When you have two identical names for those paths, the reverse method will return the last such definition for that name.

Does this seem oddly incongruent to anyone else?

(Admission: I have no specific use-case where this matters. I thought I did, but that was just a brain cramp. So file this inquiry in the category of idle speculation.)

You’re right, it does seem odd to me too - my initial impression is that they should match result-wise when this happens. Wonder if there’s any historical reason for this?

1 Like