Django框架基礎

for basic use of Django, please refer to: http://docs.djangoproject.com/en/dev/intro/tutorial01/

1. Download and install Django:


    http://www.djangoproject.com/download/

2. Create your site:

   
django-admin.py startproject mysite



3. Start your server:
    in mysite folder, run:

python manage.py runserver



Now you have a basic site with diango framwork, so simple

 

 

 

MORE:


4. Setup database support:
    change DATABASES in settings.py, then run command to create tables for your site.:

   
python manage.py syncdb

    if you use mysql, you need to download python mysql driver: MySQL-python-1.2.3.tar.gz

5. Create models

   
python manage.py startapp polls

 

  • write classes in models.py
  • Activating models by editting setting.py INSTALLED_APPS node.
  • validate your model by python manage.py validate
  • run python manage.py syncdb

 

6. Playing with Django api:

 

python manage.py shell
 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章