diff --git a/README.md b/README.md index 2521a77..85d59c5 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ The `README.md`, when viewed on github, should guide through each chapter of the In the `apps` folder, I have separated the following apps: -1. Basic django html pages `web_page` +1. Basic django html pages `web_pages` 2. Web Apps `web_app` 3. Django ORM `web_db` 4. Web / API Endpoints `web_endpoint` @@ -40,3 +40,13 @@ The instructions were written for a linux development machine. 4. Spin up a virtual environment ```mkvirtualenv djmusic && pip install -r requirements.txt && add2virtualenv `pwd`/apps ``` 5. Ensure things are working by running `./manage.py runserver` and opening a browser to `localhost:8000` + +## 1. `web_pages` + +1. `git checkout -b web_page` +2. `./manage.py startapp web_pages && mv web_pages apps/web_pages` +3. Edit `apps/django_music/urls.py` +4. Edit `apps/web_pages/views.py` +5. Create a templates directory: `mkdir -p apps/web_pages/templates/web_pages/` +6. Create a template in that directory +7. Go to the local URL you set, in our case: `localhost:8000/pages/` diff --git a/apps/__init__.py b/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apps/admin.py b/apps/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/apps/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/apps/apps.py b/apps/apps.py new file mode 100644 index 0000000..9d82e11 --- /dev/null +++ b/apps/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class WebPagesConfig(AppConfig): + name = 'web_pages' diff --git a/apps/django_music/settings.py b/apps/django_music/settings.py index 2f092ba..d008748 100644 --- a/apps/django_music/settings.py +++ b/apps/django_music/settings.py @@ -29,7 +29,7 @@ # Application definition -INSTALLED_APPS = [ +DJANGO_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -38,6 +38,12 @@ 'django.contrib.staticfiles', ] +OUR_APPS = [ + 'web_pages', +] + +INSTALLED_APPS = DJANGO_APPS + OUR_APPS + MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', diff --git a/apps/django_music/urls.py b/apps/django_music/urls.py index 32e5d23..f28c5a9 100644 --- a/apps/django_music/urls.py +++ b/apps/django_music/urls.py @@ -16,6 +16,9 @@ from django.conf.urls import url from django.contrib import admin +from web_pages.views import basic_web_page + urlpatterns = [ url(r'^admin/', admin.site.urls), + url(r'^pages/$', basic_web_page), # the web_pages app. We call the view's callable ] diff --git a/apps/migrations/__init__.py b/apps/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apps/models.py b/apps/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/apps/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/apps/tests.py b/apps/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/apps/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/apps/views.py b/apps/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/apps/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/apps/web_pages/__init__.py b/apps/web_pages/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apps/web_pages/admin.py b/apps/web_pages/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/apps/web_pages/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/apps/web_pages/apps.py b/apps/web_pages/apps.py new file mode 100644 index 0000000..9d82e11 --- /dev/null +++ b/apps/web_pages/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class WebPagesConfig(AppConfig): + name = 'web_pages' diff --git a/apps/web_pages/migrations/__init__.py b/apps/web_pages/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apps/web_pages/models.py b/apps/web_pages/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/apps/web_pages/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/apps/web_pages/templates/web_pages/basic.html b/apps/web_pages/templates/web_pages/basic.html new file mode 100644 index 0000000..fa1ba53 --- /dev/null +++ b/apps/web_pages/templates/web_pages/basic.html @@ -0,0 +1,10 @@ + + +
+ +