django學習筆記

來源:互聯網
上載者:User

標籤:sgi   nginx   ini   project   end   cti   template   django   style   

                 django學習筆記----建立疾病預測系統的web應用
                 
           
@buyizhiyou
               
工作環境:ubuntu16.04LTS+django1.10+python3.5    


more simple;more ignorant;             

1:建立medical項目,在該項目下建立一個diagnose app;
    在django內建的本機伺服器上開發項目
    MCV模式/MTV模式
    a:建立項目及app:
    django-admin startproject medical
    python manage.py runserver
    python manage.py startapp diagnose
    b:urls配置及視圖(views):
    reg匹配
    c:模板(templates):
    商務邏輯與表現邏輯的分離    
    d:靜態檔案(css/image/js):
    statics(關鍵是路徑配置)
    模板中顯示圖片 <image src="{% static ‘css/images/shulan.jpg‘ %}" alt="樹蘭">
    模板中調用css  <link rel="stylesheet" type="text/css" href="{% static ‘css/style.css‘ %}" />
    模板中調用js   <script type="text/javascript" src="{% static ‘my.js‘ %}"></script>
    e:模型(model):
    使用資料庫前,在資料庫中建立表python manage.py migrate
    在app的model.py中編寫類,對應一個表
    告訴django對models做了改變,一開始是添加了model,以後每次改變了models都要使用這條命令: Python manage.py makemigrations ***
    再次使用python manage.py migrate 為所有的models在資料庫中建立表
    開啟python的shell:python manage.py shell 對models進行操作
    f:登陸介面(login)
    http://www.cnblogs.com/fnng/p/3748043.html
    superuser:buyizhiyou/[email protected]/sqlxyz0123
    

2:部署到伺服器上(apache2+mode_wsgi   OR   ngnix+uWSGI)
    2.1:apache2+mode_wsgi
    參考部落格:http://www.jianshu.com/p/b40a4a12fff1
        a:安裝apache2+mode_wsgi:
        sudo apt-get install apache2
        sudo apt-get install libapache2-mod-wsgi-py3  #Python3
        b:建立apache2與djangol聯絡:
        將Django工程放在/var/www/下;
        sudo vi /etc/apache2/sites-available/yoursite.conf 建立設定檔;
        sudo a2ensite yoursite.conf 設定檔生效;
        sudo service apache2 restart 重啟Apache
        
        按照參考部落格上所做出現  import error: no module named django 解決辦法為在wsgi.py文  件中添加django 路徑(import sys  sys.path.append(‘/home/buyizhiyou/anaconda3/lib/python3.5/site-packages‘)
    2.2:nginx+uWSGI
    參考部落格:http://www.python88.com/topic/124/         http://www.python88.com/topic/101/    http://www.cnblogs.com/fnng/p/5268633.html
        a:安裝nginx+uwsgi:
        sudo apt-get install nginx
        /etc/init.d/nginx start  #啟動
        /etc/init.d/nginx stop  #關閉
        /etc/init.d/nginx restart  #重啟
        python3 -m pip install uwsgi
        b:配置django和uwsgi:
        配置wsgi.py檔案
        執行命令uwsgi --http :8000 --chdir /home/buyizhiyou/NLP/cnn_django/medical --module medical.wsgi
        上述命令列的參數可以寫到ini OR  xml文檔中
        c:配置nginx和uwsgi:
        這裡面由於版本更新的原因和參考教程有諸多不同之處,需要通過查看輸出error資訊調試
        /etc/nginx/conf.d目錄下建立medical.conf,裡面寫入server的配置資訊
        重啟nginx伺服器,nginx -s reload
        啟動uwsgi伺服器 uwsgi -ini  medical_uwsgi.ini
        
3:完善,最佳化(html/css/js)
    3.1:添加超連結:
    html:<a href="">超連結<a>
    超連結和重新導向
    3.2:添加管理介面:
    主介面:文字預測+特徵預測(request.GET.get方法)
    表單處理:method=post/get  ,action=‘提交資料到的url‘,
    3.3:最佳化文字預測介面和特徵預測介面
    select控制項選定的顯示
    3.4:request.session實現資料緩衝與傳遞:
    http://blog.csdn.net/shanliangliuxing/article/details/7988595
4.調用深度學習的結果,完善架構:
    4.1 安裝caffe,GPU加速配置:
    http://blog.csdn.net/yhl_leo/article/details/50961542
    三天尚未搞好。。。。。。
    NVIDIA顯卡驅動裝不上?系統問題?驅動版本問題?電腦顯卡問題?
    暫時安裝cpu版本caffe:
    opencv安裝:http://blog.csdn.net/u011762313/article/details/47263845
    caffe安裝:http://blog.csdn.net/u011762313/article/details/47262549
    4.2 調用訓練結果(predict)
    文字預測和特徵預測源碼編寫與修改(統一開發環境)
    python模組間的調用:http://www.cnitblog.com/seeyeah/archive/2009/03/15/55440.html
    4.3 virtualenv工具和virtualenvwrapper工具:
    虛擬環境,打包
    
    
    
   

django學習筆記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.