HI! 我是Maple 剛滿20歲沒多久的小朋友 請ㄅ要欺負窩QAQ
django-admin.py startproject Aboriginal
cd Aboriginal
python3 manage.py startapp omniscient
cd Aboriginal
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'omniscient',
)
from django.db import models
# Create your models here.
#儲存手工藝作業
class Works(models.Model):
Title = models.CharField(max_length = 25)
Introduction = models.TextField(blank = False)
Contact = models.TextField(blank = False)
Photo = models.ImageField(blank = False)
Add_time = models.DateTimeField(auto_now_add = False)
Edit_time = models.DateTimeField(auto_now = False)
#儲存議題資料
class Issue(models.Model):
Title = models.CharField(max_length = 25)
Context = models.TextField(blank = False)
User_name = models.CharField(max_length = 25)
Add_time = models.DateTimeField(auto_now_add = False)
Edit_time = models.DateTimeField(auto_now = False)
#儲存留言板資料
class Board(models.Model):
Context = models.TextField(blank = False)
User_name = models.CharField(max_length = 25)
Add_time = models.DateTimeField(auto_now_add = False)
Edit_time = models.DateTimeField(auto_now = False)
python3 manage.py makemigrations
(建立migration 檔案)python3 manage.py migrate
(Django 根據上面的紀錄,把 models.py 中的欄位寫入資料庫)今天就寫到這裡了。
學習ㄉ網站