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'),

image

views:

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

image

 

在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

image

 

创建成功:

image

 

查看编译后的文件

image

posted @ 2016-03-18 16:09  南湖鹄  阅读(123)  评论(0编辑  收藏  举报