2023-02-02發表Django4 分鐘讀完 (大約615個字)Django架設在Windows IIS上1. 環境準備1.1 Python 3.x安裝至Python下載頁下載Python 3.x並安裝1.2 Upgrade PIP1python -m pip install --upgrade pip繼續閱讀
2022-10-31發表Django幾秒讀完 (大約51個字)(Django)取得目前URL/app_name12345678from django.urls import resolvedef get_current_url(request): ... current_url = resolve(request.path_info).url_name app_name = resolve(request.path_info).app_name print("current_url: %s" % current_url) print("app_name: %s" % app_name)在template取得app_name1{{request.resolver_match.app_name}}
2022-08-29發表Django幾秒讀完 (大約33個字)(Django)資料庫內密碼欄位加密 - make_passwordimport make_passworduse make_password() function1234567from django.contrib.auth.hashers import make_passwordclass MyView(CreateView): ... def form_valid(self, form): pwd = form.cleaned_data['password'] pwd = make_password(pwd)