I use Django 1.10.2. While testing, launching through the "built-in" web server. Actually, the task is to add an action to the admin panel that will display the "intermediate" page:

def train_classifier(modeladmin, request, queryset): operations = [] for classifier in queryset: operations.append(classifier.train_celery().pk) context = Context({'operations': operations, 'title': 'Train classifiers'}) response = HttpResponse(get_template("operations.html").render(context)) return response train_classifier.short_description = 'Train classifiers' ... class ClassifierAdmin(admin.ModelAdmin): form = ClassifierModelForm actions = [train_classifier, test_classifier] 

On this intermediate page, upon completion of the operation, show the link back to the list of classifiers.

Why use the following code

 <a href="{{request.META.HTTP_REFERER}}">Go back</a> 

Well and such settings-related settings in settings.py

 TEMPLATES = [ { 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', ] }, 'DIRS': [ os.path.join(BASE_DIR, 'templates'), ], 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'APP_DIRS': True, } ] 

However - after the transition from the list of objects to the action - on the resulting page the template is rendered as

 <a href="">Go back</a> 

Those. {{request.META.HTTP_REFERER}} rendered as empty text. Actually, what can I do wrong (and is there any better way to do this)?

ps as a temporary solution used request.META ['PATH_INFO'].

    0