Part 5: 增加後台 import & export 功能 - amychenmit/misdj002 GitHub Wiki

pip install django-import-export

造訪 https://github.com/twoutlook/misdj002
copy .gitignore to your local folder

HOMEWORK: 看不懂,老爸的註解捏~*U*~

# 參考 https://tutorial.djangogirls.org/en/deploy/
*.pyc
*~
__pycache__
  1. 我們設置虛擬環境不在項目內,
  2. 另外我們命名為 venv
  3. myvenv
  1. 數據庫是另有考量的
  2. 先期由本地主導時,仍然上傳
  3. db.sqlite3
  1. 根據實做經驗,
  2. 本地能放幾個最近的數據庫是比較方便的。
    /db_backup

/static
.DS_Store

七步驟組合拳


1. pip install django-import-export
2. edit misdj/settings.py
3. edit note/models.py
4. ./manage.py makemigrations
5. ./manage.py migrate
6. edit note/admin.py
7. ./manage.py runserver

then visit /admin again, to see what happened

補充:
bq. 2. adding one line @ line 42 of misdj002/misdj/settings.py


    'note', # 加入 note 功能
    'import_export', # 加入 import_export 功能

3. 複製 coding @ https://github.com/twoutlook/misdj002/blob/master/note/models.py

from django.db import models



class Note(models.Model):
    seq = models.IntegerField(default=0)
    subject = models.CharField(max_length=200)
    detail = models.TextField(null=True, blank=True)

    def __str__(self):
        return self.subject

        

測試 import & export 功能^_^
並且確認前台也同步更新

add line to README

#完成 import & export

將本地代碼上傳到 github 的組合拳

- git add .
- git status
- git commit -m"implement import-export"
- git status
- git push -u origin master
⚠️ **GitHub.com Fallback** ⚠️