Django~Models2

Generally, each model maps to a single database table.

  • Each attribute of the model represents a database field.
    • Each attribute of the model represents a database field.

manage.py startapp mymodel

urls:url(r'^$',views.index,name='index'),

Django~Models2

views:

def index(request):
    return HttpResponse("Hello My model")

Django~Models2

在project中添加urls

urlpatterns = [
    url(r'^Mymodel/',include('Mymodel.urls')),

app添加

INSTALLED_APPS = [
#    'test',  #db
#    'excel.apps.excelConfig',
#    'Hello.apps.HelloConfig',
    'Mymodel.apps.MymodelConfig',

编译数据库中建表:

manage.py makemigrations

mangae.py migrate

No module named mymodelConfig

Django~Models2

创建成功:

Django~Models2

查看编译后的文件

Django~Models2

上一篇:Nuxt框架实践


下一篇:SPRING IN ACTION 第4版笔记-第三章ADVANCING WIRING-002-激活PROFILE、设置默认值、@ActiveProfiles