How to get the current URL within a Django template?

Django 1.9 and above: ## template {{ request.path }} # -without GET parameters {{ request.get_full_path }} # – with GET parameters Old: ## settings.py TEMPLATE_CONTEXT_PROCESSORS = ( ‘django.core.context_processors.request’, ) ## views.py from django.template import * def home(request): return render_to_response(‘home.html’, {}, context_instance=RequestContext(request)) ## template {{ request.path }}

Can I access constants in settings.py from templates in Django?

If it’s a value you’d like to have for every request & template, using a context processor is more appropriate. Here’s how: Make a context_processors.py file in your app directory. Let’s say I want to have the ADMIN_PREFIX_VALUE value in every context: from django.conf import settings # import the settings file def admin_media(request): # return … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)