1. Install Python and Django, refer to the online tutorial (install python, configure path, install Django, configure path ...)
2. View the Django installation version: Cmd-->python-->import django-->django.get_version ()
3. Build a Django Web project: cmd-to the directory where you want to create the project-->django-admin.py startproject my_django_website or Python django-admin Startproject My_django_website (in the current directory, create a folder named My_django_website, containing manage.py files and My_django_website folders, meaning the following:)
- my_django_website: the container for the project.
- manage.py: a useful command-line tool that allows you to work with the django in a variety of ways Interact with the project.
- my_django_website/__init__.py: an empty file that tells Python The directory is a Python package.
- my_django_website/settings.py: the django Setup/configuration of the project.
- my_django_website/urls.py: the Django The URL statement of the project; a "directory" of the Django -driven website.
- my_django_website/wsgi.py: a WSGI Access to a compatible Web server to run your project.
If prompted: django-admin.py is not an internal or external command, locate the django-admin.py file from the Python installation directory, copy it to the current folder, and then execute the appropriate command. For example my directory is: D:\Program Files\python 3.5.1\lib\site-packages\django-1.10-py3.5.egg\egg-info\scripts
4, set the server port number:
CMD into the My_django_website folder (manage.py file under folder), execute Python manage.py runserver 9000, set the current project's running port to 9000, if not set, The default is 8000. When the cmd window is closed, the server stops.
5, according to the project created by the urls.py format in the main, and some urls.py format is:
Urlpatterns = Patterns (", # uncomment the next line to enable the admin: # (R ' ^admin/', include (Admin.site.urls)) ,)
Some are:
From django.conf.urls import urlfrom django.contrib Import admin urlpatterns = [ url (R ' ^admin/', admin.site.urls),]
The reason is that different versions of the Django formation of the differences, in the addition of their own file path is also in the relative format, or may be error, such as the urls.py format is the second, the use of the first will be the error: ' Parterns ' is not defined.
6, command line input: Python manage.py migrate, will build a powerful CMS based on the existing model of Django, in the old version, using Python mangae.py synadb, and automatically create users.
7, command line input: Python mange.py createsuperuser, according to the prompt to fill in the user name, mailbox, password, you can create a user name, under localhost:9000/admin Use this user name can log into the CMS backend system (port number for the front Python manage.py runserver 9000 setting)
Django Learning note 1.--creating a project