Setup python3 environment
mkvirtualenv --python=python3 django-girl
Install django
pip install django==1.8
Init project
django-admin startproject mysite .
tree .
.
├── manage.py
├── mysite
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── notes.md
1 directory, 6 files
Config settings
change the following settings:
vim ./mysite/settings.py
# change timezone
TIME_ZONE = 'Asia/Hong_Kong'
# add abs path for local file operation
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
Init/Migrate database
> python manage.py migrate
Operations to perform:
Synchronize unmigrated apps: staticfiles, messages
Apply all migrations: sessions, auth, admin, contenttypes
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying sessions.0001_initial... OK
Start server
Execute the following:
# start server on a running port 8000
python manage.py runserver 0:8000
Go back to your browser, it should have something like this:
It worked!
Congratulations on your first Django-powered page.
Of course, you haven't actually done any work yet. Next, start your first app by running python manage.py startapp [app_label].
You're seeing this message because you have DEBUG = True in your Django settings file and you haven't configured any URLs. Get to work!