What does {{ name }} this mean in Django Templates? {{ name }} will be the output. It will be displayed as name in HTML. The name will be replaced with values of Python variable.
A Django template is a text document or a Python string marked-up using the Django template language. Some constructs are recognized and interpreted by the template engine. The main ones are variables and tags. A template is rendered with a context.
Make sure you have rest_framework
listed in your settings.py
INSTALLED_APPS
.
Please note that the DRF attempts to return data in the same format that was requested. From your browser, this is most likely HTML. To specify an alternative response, use the ?format=
parameter. For example: ?format=json
.
The TemplateDoesNotExist
error occurs most commonly when you are visiting an API endpoint in your browser and you do not have the rest_framework
included in your list of installed apps, as described by other respondents.
If you do not have DRF included in your list of apps, but don't want to use the HTML Admin DRF page, try using an alternative format to 'side-step' this error message.
More info from the docs here: http://www.django-rest-framework.org/topics/browsable-api/#formats
For me, rest_framework/api.html
was actually missing on the filesystem due to a corrupt installation or some other unknown reason. Reinstalling djangorestframework
fixed the problem:
$ pip install --upgrade djangorestframework
Not your case, but also possible reason is customized loaders
for Django
. For example, if you have in settings (since Django 1.8
):
TEMPLATES = [
{
...
'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'
],
'loaders': [
'django.template.loaders.filesystem.Loader',
],
...
}
}]
Django will not try to look at applications folders with templates, because you should explicitly add django.template.loaders.app_directories.Loader
into loaders
for that.
Notice, that by default django.template.loaders.app_directories.Loader
included into loaders
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With