[Django]-Django Rest shows TemplateDoesNotExist

5👍

Make sure to add rest_framework to INSTALLED_APPS in your project’s settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    ................

You may also need to run migrations after adding it.

Everything about your code seems alright

1👍

Django rest framework will provide a template by default. i wonder if something is not done right when setting up the application? Possibly template paths? Have you tried hitting the endpoint with a REST client or curl? Something like:

curl -X "GET" "http://127.0.0.1:8000/api/postings/1" -H "Accept: application/json"

I would expect the above to work. In that case have a look at your template paths (although the HTML template is not required for a REST API.

Leave a comment