Skip to main content

Command Palette

Search for a command to run...

Django - forgot username & password

Updated
1 min read
Django - forgot username & password

Four months ago, I started a django project with the admin module, but soon stopped using . Yesterday, I tried to start it and found that I forgot the admin password.

How to get it back? Let's use the python shell.

Using the Python shell (in terminal)

python manage.py shell

Import module

from django.contrib.auth.models import User

List superuser / all user

# superuser
User.objects.filter(is_superuser=True)

# all user
User.objects.all()

Note down your name and use it in the next step.

Change password

user = User.objects.get(username='name') 
user.set_password('password')
user.save()

Wow, I found my password back ;)

More from this blog

網路字型的好幫手 FontForge

FontForge 是一套免費(歡迎抖內)的字型編輯軟體,提供了圖形化的操作介面,還支援直接用 script 操作。 它可以: 透過軟體介面編輯製作字型,想發明什麼字型都沒問題 從現有的免費字型中抽取所需的字圖輸出成新字型 匯入 svg 檔案組合成字型檔 字型間的轉檔 例如:ttf 檔 轉 woff 更多更多⋯⋯請看 官方說明文件 更吸引人的是~ 它內建支援 python,只要你的電腦環境有安裝 python,安裝 fontforge 之後就能把它當成套件來使用~ 巴特!光是下...

May 25, 20221 min read
網路字型的好幫手 FontForge

CSS 製作友善列印(print friendly)

在一些以文字內容為主的網站,常常會看到「友善列印」(print friendly) 的功能, 這功能提供使用者可以方便列印文字內容,不想印出來的導覽列啦、選單啦,通通都給它變不見。 傳統的作法是用 javascript 把本文送去一個新的視窗,再來進行列印, 但現在透過 CSS 的 Media Queries 不需要任何一行程式碼,就能完成列印時的頁面設定喔! 只要在 CSS 裡面加上屬於 print 的設定: @media print { *{ backgrou...

May 23, 20221 min read
CSS 製作友善列印(print friendly)

用 CSS 取用 fontawesome 圖示

Font Awesome 是我蠻喜歡的圖示字型服務,因為它入手相當簡單,適合像我這種小白使用,圖示種類也蠻豐富可愛的。 最常見的用法是找到你要的圖示,比方說底下這個紅蘿蔔: https://fontawesome.com/v5/icons/carrot?s=solid 直接把它提供的 HTML 貼到想放的位置就可以了~ <i class="fas fa-carrot"></i> 一般像是按鈕或選單用到的圖示,只要貼上去就好啦! 巴特,又是那個巴特,如果今天想在每一個段落前都給它一個紅...

May 22, 20221 min read
用 CSS 取用 fontawesome 圖示

White Bunny's Notes

5 posts

Learn a little every day.