How to know the current path in django website at any page?


I want to create a url and for that I want to know the current path of page.

asked 2 years ago
Reputation: 1

1 Answer


To know the current path we need to add the request context preprocessor to In most cases it should already be present but if it’s not there then make sure it’s added properly.

It should look something like the code below in

        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [ ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [


html template

Use {{request.path}} to show current url path.

That’s it.

answered 2 years ago
Reputation: 1

Your Answer

Nothing to preview

Post Answer

Asked:  2 years ago
Viewed:  640 times
Active:  2 years ago