1Eclipse,PyDev,Django都安装好之后,打开Eclipse,新建一个PyDev Django Project
?
?
2起项目名称,选Python版本,和解释器,然后nextnext
?
?
?
建好的项目目录结构就像这样
以下是官方解释These files are:
- The outer?mysite/?root directory is just a container for your project. Its name doesn’t matter to Django; you can rename it to anything you like.
- manage.py: A command-line utility that lets you interact with this Django project in various ways. You can read all the details about?manage.py?in?django-admin.py and manage.py.
- The inner?mysite/?directory is the actual Python package for your project. Its name is the Python package name you’ll need to use to import anything inside it (e.g.?mysite.urls).
- mysite/__init__.py: An empty file that tells Python that this directory should be considered a Python package. (Readmore about packages?in the official Python docs if you’re a Python beginner.)
- mysite/settings.py: Settings/configuration for this Django project.?Django settings?will tell you all about how settings work.
- mysite/urls.py: The URL declarations for this Django project; a “table of contents” of your Django-powered site. You can read more about URLs in?URL dispatcher.
- mysite/wsgi.py: An entry-point for WSGI-compatible web servers to serve your project. See?How to deploy with WSGI?for more details.
?
?
?
3然后启动命令行,cd到刚才新建项目的目录,我这里是helloDjango
?
第一次运行需键入如下命令python manage.py migrate
?
然后再打manager.py runserver,启动服务器
?
?
?这时在Eclipse中右击刚才那个项目名?,在RUN as 中有了PyDev Django,点击这个也能启动服务器,这个才方便,运行之后如下,和命令行里是一样的,以后要运行服务器只要run as PyDev Django 就可以了。
?
4访问http://localhost:8000/
?