Reputation: 13079
In my urls.py, I direct traffic like this:
url(r'^basic/', 'mysite.views.basicHandler', name='basic'),
Which is handled in my views.py like this:
from django.shortcuts import render_to_response as dr2r
def basicHandler( request ):
rc = RequestContext(request, {
"cdn_url" : settings.CDN_BASE_URL,
"cdn_home" : settings.CDN_SITE_PATH
})
return dr2r( 'basic.html', {}, context_instance=rc )
My question is, how can my views handler (basicHandler
) access the url pattern (r'^basic/'
)? Is that inside of the request object?
Upvotes: 0
Views: 763
Reputation: 99620
Yes, you can get it from the request.META
object.
referer = request.META.get('HTTP_REFERER')
Alternatively, you can resolve the URL using reverse()
method
from django.core.urlresolvers import reverse
url = reverse('basic')
Upvotes: 1