0

When I execute it from this point:

  1. Firswt I log in to the Application (the authentication system is created using the one from DJango)

  2. Eventually, I will land on a HTML template that runs the code below

    {% csrf_token %}

The code above calls he following:

@login_required
def homepage(request):
    app_logonid = request.user.username
    return render(request, 'mainadmin/base.html', { 'firstname': app_logonid }, )

When following this sequence of steps, I get the following warning:

A {% csrf_token %} was used in a template, but the context did not provide the value. This is usually caused by not using RequestContext.

Why am I getting this and how can I resolve it?

TIA

Update

Below is the templates setting:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ['templates', ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]
Casey Harrils
  • 2,793
  • 12
  • 52
  • 93

0 Answers0