mindcurrent / djanky-django

Daniel's Janky Attempt at a Django RESTful API Server
0 stars 1 forks source link

Create First Django App: "Polls" View #8

Open dpcunningham opened 4 years ago

dpcunningham commented 4 years ago

Note that per the previous Python-Django version issues, I will slightly deviate from the instructions to use python3 as follows:

$ ls -R
.:
db.sqlite3  djankysite  manage.py

./djankysite:
__init__.py  __pycache__  settings.py  urls.py  wsgi.py

./djankysite/__pycache__:
__init__.cpython-36.pyc  settings.cpython-36.pyc  urls.cpython-36.pyc  wsgi.cpython-36.pyc

$ python3 manage.py startapp polls

No messages returned (error, notification or success). Great. Hope that worked. Let's see...

$ ls -R 
.:
db.sqlite3  djankysite  manage.py  polls

./djankysite:
__init__.py  __pycache__  settings.py  urls.py  wsgi.py

./djankysite/__pycache__:
__init__.cpython-36.pyc  settings.cpython-36.pyc  urls.cpython-36.pyc  wsgi.cpython-36.pyc

./polls:
admin.py  apps.py  __init__.py  migrations  models.py  tests.py  views.py

./polls/migrations:
__init__.py

OK, recon so. New ./polls subdir. Moving on...

$ cd polls
$ vi views.py  # Add their code
$ touch urls.py
$ vi urls.py  # ...and some more
$ ls -l  ./urls.py ../djankysite/urls.py
-rw-r--r-- 1 dpc dpc 752 Oct  1 14:37 ../djankysite/urls.py
-rw-r--r-- 1 dpc dpc 207 Oct  2 14:00 ./urls.py
$ vi ../djankysite/urls.py  # ...and some final touches

Let's see if this baby works!

$ pwd
/home/dpc/dpc.data/local.FS/lfs.03-Projects.Active/project.MindCurrent/dev/python/djankysite
$ python3 manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.

October 02, 2019 - 21:24:10
Django version 2.2.6, using settings 'djankysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[02/Oct/2019 21:24:18] "GET /polls/ HTTP/1.1" 200 40
[02/Oct/2019 21:24:20] "GET /polls/ HTTP/1.1" 200 40
[02/Oct/2019 21:24:21] "GET /polls/ HTTP/1.1" 200 40

Yay!