2.3.2 Webpage URL

Now that our webpage has data, we must create a URL for it. In Chapter 5, we see how to create URLs for each app separately. For the moment, however, we simply use the project-wide URL configuration.

To tell Django of the existence of the webpage created by greeting(), we must make changes to /suorganizer/urls.py. Open the file and import our new function by adding from helloworld.views import greeting to the end of the import list, just as you would import any Python function. We then direct Django to our webpage by adding an item to the urlpatterns list. The argument we add is url(r'^$', greeting). The contents of the file should now be as shown in Example 2.4.

Example 2.4: Project Code

suorganizer/urls.py in 98a8ef0d11

Get Django Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.