First you have to make sure that you have Python installed on your machine, and secondly, you have to make sure that you have Django installed on it.
Next, we can get into the first Django application
Very simple operation, that is, to enter the code at the Windows terminal:
Copy Code code as follows:
1 django-admin.py startproject MySite
Can be, such as: I am in the E:\Python33\python_workspace directory of my Computer to create a project
You set the catalogue yourself.
To run the command:
Copy Code code as follows:
django-admin.py Startproject MySite
#意思是创建一个以mysite命名的应用程序
The next step is to enter: E:\Python33\python_workspace\mysite directory
Note: Here must be advanced to the MySite directory, otherwise, will fail drop!!!!
To run the code:
Copy Code code as follows:
Python manage.py runserver 8080
#意思是启动服务, Port is: 8080, if the port is not set, the default is: 80000
The following figure:
Started the service, then we can now access through the browser
In the browser address bar, enter: http://localhost:8080
By now, your first Django application is a success!!!
Problems encountered and solutions:
1.importerror:no module named Django.core
Analysis and Solutions: This is the problem when you run the command: django-admin.py startproject MySite, and it's OK
The Django on your own machine has been successfully installed and can be passed:
Copy Code code as follows:
Python-c "Import Django;print (Django.get_version ())"
To verify, and secondly, the django-admin.py has been added to the environment variable:
Copy Code code as follows:
#加入到path环境变量中 #django的安装目录
E:\Python33\Lib\site-packages\django\bin
I did both of the above, but there was an error, and I found out the reason for the problem: there are too many Python versions installed on my computer: python2.7.5,python32,python33
Finally put the Python2.7.5,python32 uninstall, leaving only Python33, and then run, Success!!!
2.python:can ' t open file ' manage.py '
This is similar to the reason above, the solution, but also version of the conflict, the other uninstall off, leaving only PYTHON33, successful!!!