[Answered ]-Adding username in url after base url in django

1👍

You can pass a kwargs dict to your reverse and reverse_lazy function in order to mapping it with your url pattern.

reverse_lazy('myapp:profile', kwargs={'username': username})

And in your template, just pass it as positional argument

<a href="{% url 'myapp:profile' username %}">
👤levi

1👍

Your base url doesn’t need to mention myapp at all, just set your url that includes myapp to r'^'. You can still namespace the urls and everything the same as before.

👤Sayse

Leave a comment