Create the app
This is the mysite directory.
Creating "hello"
into a Bash console which created these files:
Connect the view
In order to link the view to the site there are a few things that need to be done. First I updated the hello/views.py file to look like this:
I then had to create a new urls.py file for the hello directory, this is done by just creating a new file and updating it like so:
creating the file
hello/urls.py
Next I had to link this to the mysite/urls.py file:
Lets see if it worked!
Running the command python manage.py runserver 8002 starts a server with the port number 8002.
Now if I go to my domain name and specifically the hello page at jpernick.pythonanywhere.com/hello we can see that it worked! The page is displayed with the message.
Thank you for reading! Next week I will be creating a polling application using a couple cool features in Django. Please comment your thoughts and anything you would like to see in future blogs!
No comments:
Post a Comment