This document provides instructions for setting up a basic Django project. It shows how to create a virtual environment, install Django, start a new project called "mysite", and create an app called "polls". It demonstrates making migrations and migrating the database to create a Question model. The instructions include running the development server, configuring URLs, adding the polls URLs, creating a view and template, and more. Overall it outlines the basic steps to build a simple Django application.
24. $ cat manage.py
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
25. $ ./manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
You have 14 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.
June 10, 2018 - 08:07:07
Django version 2.0.6, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[10/Jun/2018 08:07:44] "GET / HTTP/1.1" 200 16348
[10/Jun/2018 08:07:44] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
[10/Jun/2018 08:07:44] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/
1.1" 200 81348
[10/Jun/2018 08:07:44] "GET /static/admin/fonts/Roboto-Regular-webfont.woff