bojack
bojack

Reputation: 73

Why won't my index.html file be found in directory?

I'm 100% sure my path is correct in my code, why is it giving me TemplateDoesNotExist error? I can't see how this is possible.

I tried:

settings.py > TEMPLATES > Dirs: [/template/music]

and a laundry list of other things on SO but it doesn't rectify my problem.

enter image description here

Here's my views.py file:

from django.http import HttpResponse
from django.template import loader

def index(request):
    template = loader.get_template('music/index.html')
    return HttpResponse(template.render())

def detail(request, user_id): # Testing out page 2
    return HttpResponse("<h2>Page # (testing this out) " + str(user_id) + "</h2>")

Here's my index.html file:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>The Page</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>

<body>
    <div class="container">
        <form action="#">
            <div class="form-group">
                <label for="firstName">First Name:</label>
                <input type="email" class="form-control" id="firstName" placeholder="Enter first name" name="firstName">
            </div>
            <div class="form-group">
                <label for="">Last Name:</label>
                <input type="email" class="form-control" id="lastName" placeholder="Enter last name" name="lastName">
            </div>
        </form>
            <div class="checkbox">
                <label><input type="checkbox" name="remember">Remember me</label></div></br>
                <button type="submit" class="btn btn-default">Submit</button>
            </div>
    </div>
</body>
</html>

Upvotes: 0

Views: 174

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599778

Your templates directory is inside migrations. Move it out of there.

Upvotes: 3

Related Questions