Skip to content

Commit

Permalink
Web pages
Browse files Browse the repository at this point in the history
  • Loading branch information
octaflop committed Sep 2, 2017
1 parent 6a23f5f commit 72fd2fe
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 2 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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/`
Empty file added apps/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions apps/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions apps/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class WebPagesConfig(AppConfig):
name = 'web_pages'
8 changes: 7 additions & 1 deletion apps/django_music/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

# Application definition

INSTALLED_APPS = [
DJANGO_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand All @@ -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',
Expand Down
3 changes: 3 additions & 0 deletions apps/django_music/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Empty file added apps/migrations/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions apps/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
3 changes: 3 additions & 0 deletions apps/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions apps/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
Empty file added apps/web_pages/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions apps/web_pages/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions apps/web_pages/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class WebPagesConfig(AppConfig):
name = 'web_pages'
Empty file.
3 changes: 3 additions & 0 deletions apps/web_pages/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
10 changes: 10 additions & 0 deletions apps/web_pages/templates/web_pages/basic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>This is a very basic web page hosted with django</title>
</head>
<body>
<h2>This is a very basic web page hosted with django</h2>
</body>
</html>
3 changes: 3 additions & 0 deletions apps/web_pages/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
7 changes: 7 additions & 0 deletions apps/web_pages/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.shortcuts import render


def basic_web_page(request):
ctx = {}
template_name = 'web_pages/basic.html'
return render(request, template_name, ctx)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Django==1.11.4
ipython==6.1.0

0 comments on commit 72fd2fe

Please sign in to comment.