手记

python + django 第一天

一、初始配置
1、pip install Django==1.11.7
2、python setup.py install
3、import django
4、django-admin startproject efakc
5、python manage.py runserver 9999
6、python manage.py startapp appname
7、urls配置:
from django.conf.urls import url,include
from django.contrib import admin

                    urlpatterns = [
                    url(r'^admin/', admin.site.urls),
                    url(r'^blog/',include('blog.urls')),
                     ]

                     from django.conf.urls import url
                    from . import views
                   urlpatterns = [
                   url(r'^index/$',views.index),
                     ]

二、Models
1、字段属性https://docs.djangoproject.com/en/1.10/ref/models/fields/
2、数据迁移 python manage.py makemigrations app名
python manage.py migrate
查看:python manage.py sqlmigrate app名 0001
class Article(models.Model):
titel=models.CharField(max_length=32)
content=models.TextField(null=True)

1人推荐
随时随地看视频
慕课网APP

热门评论

select * from emp;

查看全部评论