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)

【转自慕课】https://www.imooc.com

Python

python list 基础知识

2022-3-3 7:53:45

Python

python中的*args和**kw

2022-3-3 8:01:18

搜索