#Issue when using copy of base.html from rest_framework

1 messages · Page 1 of 1 (latest)

fleet orbit
#
Exception Type: TemplateSyntaxError at /events/
Exception Value: 'optional_logout' did not receive value(s) for the argument(s): 'csrf_token'
#

I'm thinking that my template is not able to load the templatetags file form Django REST framework.

#

But here is my app/middle were everything looking right fot me :

Django Version: 5.0.3
Python Version: 3.11.8
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'daphne',
 'django.contrib.staticfiles',
 'corsheaders',
 'rest_framework',
 'django_eventstream',
 'django_celery_results',
 'django_celery_beat',
 'puml_generator',
 'drf_spectacular',
 'drf_spectacular_sidecar',
 'app']
Installed Middleware:
['corsheaders.middleware.CorsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django_grip.GripMiddleware']
#

I have tried to find some info about that but nothing.

#

Do i need to reproduce the templatetags in my own app ?

#

Thanks for help !

fleet orbit
#

please

urban dagger
#

Why exactly are you extending DRF's base.html ?

#

And the reason you're getting that error is because this template expects csrf_token in the context.

fleet orbit
fleet orbit
#

I would like to replace the response field to display the SSE stream.

#

But that not possible by default

#

How can I be sure that csrf_token is send to the templatags ?

urban dagger
#

Well, this template is intended to be served by the corresponding view. DRF views are feeding the context to the template. Even if you resolve the csrf_token you will land on other errors.

I can't be of more help on this subject as I haven't overriden DRF's templates before.

fleet orbit