django中cookiecutter的使用教程
導(dǎo)入:pipenv install cookiecutter
問題:在導(dǎo)入的過程中可能會報(bào)錯:
pkg_resources.VersionConflict: (importlib-metadata 3.1.0 (/Users/apple/.local/share/virtualenvs/testProject-h0hp04R9/lib/python3.6/site-packages), Requirement.parse(’importlib-metadata<2,>=0.12; python_version < '3.8'’))。
原因及解決:這個問題的出現(xiàn)主要是pipenv版本不支持,需要更新pipenv,使用命令:pip3 install -U pipenv,然后重新導(dǎo)入即可。
二、創(chuàng)建項(xiàng)目運(yùn)行cookiecutter
問題:直接報(bào)錯zsh: command not found: cookiecutter
解決辦法:使用pipenv --py獲取python環(huán)境的安裝目錄,在該目錄下運(yùn)行cookiecutter
運(yùn)行之后會繼續(xù)報(bào)錯:缺少Template
Usage: cookiecutter [OPTIONS] TEMPLATE [EXTRA_CONTEXT]...Try ’cookiecutter -h’ for help.Error: Missing argument ’TEMPLATE’.
在github中找到pydanny/cookiecutter-django,賦值github地址,把地址寫在python運(yùn)行環(huán)境的后邊,再次運(yùn)行
/Users/apple/.local/sha~~~~re/virtualenvs/testProject-h0hp04R9/bin/cookiecutter https://github.com/pydanny/cookiecutter-django.git
成功進(jìn)入配置選項(xiàng),進(jìn)行具體的配置
三、具體配置 project_name:項(xiàng)目名字 project_slug:默認(rèn)和項(xiàng)目的名字保持一直,不必填寫 description:項(xiàng)目的簡單描述 author_name:作者的名稱,格式 名字 domain_name:網(wǎng)站域名 eamil:郵箱 version [0.1.0] Select open_source_license: 選擇是否開源類型 timezone:時區(qū)設(shè)置,Asia/Shanghai windows:是否使用的是windows系統(tǒng)開發(fā) use_pycharm:是否使用pycharm use_docker:是否使用docker Select postgresql_version:選擇postgresql的版本,默認(rèn)為最新版,并且默認(rèn)沒有繼承Mysql~~~~ Select js_task_runner:js的運(yùn)行器,使用默認(rèn)的 Select cloud_provider:默認(rèn) Select mail_service:選擇email的服務(wù) use_async:是否使用異步編程 use_drf:是否使用django rest_framework,前后端分離的話選擇y custom_bootstrap_compilation:是否自定義bootstrap壓縮 use_compressor:用于壓縮js、css的技術(shù),需要選擇y use_celery:是否使用celery,使用選擇y use_mailhog:第三方的郵件發(fā)送服務(wù) use_sentry:是否使用錯誤日志監(jiān)控 use_whitenoise:用于部署靜態(tài)文件的,帶有文件壓縮功能 use_heroku:國外有名的pass平臺,如果要部署到上邊的話選擇y會自動生成對應(yīng)的配置 Select ci_tool:選擇工具(None/Travis/Gitlab/Github) keep_local_envs_in_vcs:是否在本地環(huán)境變量中使用版本配置,選擇y debug:是否使用debug,選擇y 四、問題:項(xiàng)目在進(jìn)行數(shù)據(jù)遷移的時候可能會報(bào)錯:
File '/Users/apple/.local/share/virtualenvs/django-pro-7n8-wfJY/lib/python3.6/site-packages/django_celery_beat/models.py', line 60, in crontab_schedule_celery_timezone choice[0].zone for choice in timezone_field.TimeZoneField.CHOICESAttributeError: type object ’TimeZoneField’ has no attribute ’CHOICES’
原因:django-celery-beat setup.py有一個https://github.com/celery/django-celery-beat/blob/master/requirements/default.txt依賴要求,強(qiáng)制django-timezone-field只能使用>=4.0和<5.0版本的,開發(fā)者推送了一個4.1.1版本的django-timezone-field,中斷了數(shù)據(jù)遷移過程。
解決辦法:pipenv install django-timezone-field==4.0,重新執(zhí)行數(shù)據(jù)遷移就可以了
總結(jié)到此這篇關(guān)于django中cookiecutter使用教程的文章就介紹到這了,更多相關(guān)django中cookiecutter使用內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. jstl 字符串處理函數(shù)2. JSP動態(tài)網(wǎng)頁開發(fā)原理詳解3. XHTML 1.0:標(biāo)記新的開端4. Vue中使用Echarts儀表盤展示實(shí)時數(shù)據(jù)的實(shí)現(xiàn)5. 深入理解JavaScript中的Base64編碼字符串6. java 字符串轉(zhuǎn)化為字符數(shù)組的3種實(shí)現(xiàn)案例7. JSP頁面的靜態(tài)包含和動態(tài)包含使用方法8. WAP建站W(wǎng)ML語言語法基礎(chǔ)教程第1/6頁9. 基于python實(shí)現(xiàn)判斷字符串是否數(shù)字算法10. PHP擴(kuò)展之URL編碼、解碼及解析——URLs
