Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Go to the project folder (e.g. /opt/ece_li_scheduling/ece_li_scheduling) where the settings.py file is stored.

  • In the settings.py file, add the name of the new app to the INSTALLED_APPS list:

    Code Block
    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        '<app name>',
    ]
  • In the urls.py file, direct all traffic for the new app to its .urls file.

    Code Block
    urlpatterns = [
        path('admin/', admin.site.urls),
        path('<app name>/', include('<app name>.urls'))
    ]

    Note that include needs to be imported from django.urls.

Create urls.py

Since the project urls.py directs traffic to the app, the app needs to handle this traffic with its own urls.py file.

  • Create a urls.py file within the app folder. Here is an example,

    Code Block
    from django.urls import path
    from . import views
    
    urlpatterns = [
        path('', views.home, name='home'),
    ]

    Note that this example points to a home function in the app views, but this has not been created yet.

Create view

The app needs at least one view.

...