-
Notifications
You must be signed in to change notification settings - Fork 17
6. Add the landing page to the app
Katie House edited this page Sep 15, 2020
·
3 revisions
The file mysite/urls.py
determines which view function the HTTP request will map to when the client makes a URL request. For example, in the local django web app, the home page will load with the URL http://localhost:8000/
or a URL path of ''
. When this happens, we want to map to the home()
function in iris/views.py
to render the home page.
To do this, change the mysite/urls.py
to the following:
from django.contrib import admin
from django.urls import path
from iris import views
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.home, name='home'),
]
Now, we must add the home() function to iris/views.py
:
from django.shortcuts import render
def home(request):
return render(request, 'home.html')
Finally, we need to create a home.html
file to render for the landing page. To do this, add the following file iris/templates/home.html
. Notice we are creating a new templates/
folder.
In iris/templates/home.html
, add this:
<h1>Hello Django World</h1>
Check your new landing page works with:
python manage.py runserver
You should see:
- Install Django
- Create Django Project
- Run your project for the first time
- Create a Django App
- Add app to INSTALLED_APPS
- Add the landing page to the app
- Make the landing page fancy with Bootstrap
- Create a machine learning model with the Iris dataset
- Create Django form to take in user input and send back model prediction
- Update model prediction with text and an image
- Define the SQLite Database Schema
- Use admin mode to see edit database
- Save Prediction data to SQLite database