How to use HTML page in Django
1 ) Create templates folder inside the application folder
2 ) Create home.html file inside the template folder
Inside home.html
<p>my first HTML page </p>
3 ) Change views.py like this
from django.shortcuts import render
# Create your views here.
def home(request):
return render(request,'home.html')
4 ) Change urls.py like this
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'perfumes.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^home/$','perfum.views.home', name='home'),
)
5 ) Add app name to settings.py
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'perfum',
)
2 ) Create home.html file inside the template folder
Inside home.html
<p>my first HTML page </p>
3 ) Change views.py like this
from django.shortcuts import render
# Create your views here.
def home(request):
return render(request,'home.html')
4 ) Change urls.py like this
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'perfumes.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^home/$','perfum.views.home', name='home'),
)
5 ) Add app name to settings.py
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'perfum',
)
Comments
Post a Comment