Reputation: 339
I have created a template following the django book example as the next:
<html>
<head>
<title>Search</title>
</head>
<body>
<form action="/search/" method="get">
<input type="text" name="q">
<input type="submit" value="Search">
</form>
</body>
</html>
My views is:
def search_form(request):
return render_to_response(request, 'search_form.html')
and my settings:
import os
RUTA_PROYECTO = os.path.dirname(os.path.realpath(__file__))
TEMPLATE_DIRS = (os.path.join(RUTA_PROYECTO ,'templates'),)
It should work but when I run the sever i get the TemplateDoesNotExist
Upvotes: 0
Views: 184
Reputation: 874
Comment out:
TEMPLATE_DIRS = (os.path.join(RUTA_PROYECTO ,'templates'),)
Use TEMPLATE_DIRS when you want to store template in some location outside your project folder.
Change
def search_form(request):
return render_to_response(request, 'search_form.html')
To
def search_form(request):
return render_to_response(request, 'mywebsite/search_form.html')
You have to specify what app's template you want to pull. Otherwise two different apps with the same template name won't work. If you specify a TEMPLATE_DIRS, it will be probed if Django can't find the requested template in that app folder.
Upvotes: 1