I'm trying to get started on a simple project to display a bit of HTML. However when I run my code I cannot seem to locate the html file. I am following what the tutorial on the Django website says
"Within the templates directory you have just created, create another directory called polls, and within that create a file called index.html. In other words, your template should be at polls/templates/polls/index.html. Because of how the app_directories template loader works as described above, you can refer to this template within Django simply as polls/index.html."
SO I put my index.html into
homepage/templates/homepage/index.html
I have not yet added anything to my models.py
proj urls.py:
from django.conf.urls import include, url, patterns
urlpatterns = patterns('',
url(r'homepage/',include('homepage.urls', namespace = "homepage")),
)
app urls.py
from django.conf.urls import patterns, url
from homepage import views
urlpatterns = patterns('',
url(r'^$', views.index, name = 'index'),
)
views.py:
from django.http import HttpResponse
from django.template import RequestContext, loader
def index(request):
template = loader.get_template('homepage/index.html')
return HttpResponse(template)
)
******UPDATE************
So with a bit of tinkering I seem to be able to grab the HTML file. However, the display of this HTML file is not behaving correctly. For instance, if I were to have this bit:
<!DOCTYPE html>
<html>
<body>
<form>
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname">
</form>
</body>
</html>
The output would be a blank page. The page source would display:
<Text Node: '<!DOCTYPE html>
<html>
<b'>
Not sure why it is behaving this way. Would it have to do withi my having django-pipeline installed and also twitter bootstrap?