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'),
views:
def index(request):
return HttpResponse("Hello My model")
在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
创建成功:
查看编译后的文件