django-tailwind
- 下記のパッケージをインストールして試してみる。 github.com
インストール
python3.9 -m pip install django-tailwind
設定
ー 下記のコマンドを実行する
# python3.9 manage.py tailwind init theme Tailwind application 'theme' has been successfully created. Please add 'theme' to INSTALLED_APPS in settings.py.
settings.pyファイルにtailwindとthemeを追加する
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'tailwind',
'theme'
]
TAILWIND_APP_NAME = 'theme'
- 下記のコマンドを実行した時にnodeをインストールしてくださいというメッセージが出力されたので、このパッケージを利用する意味がないので、
# python3.9 manage.py tailwind install
CommandError:
It looks like node.js and/or npm is not installed or cannot be found.
Visit https://nodejs.org to download and install node.js for your system.
If you have npm installed and still getting this error message, set NPM_BIN_PATH variable in settings.py to match path of NPM executable in your system.
Example:
NPM_BIN_PATH = "/usr/local/bin/npm"
- CDN指定するか、
<head> ... <link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet"> ... </head>
nodeをインストールして下記のページを参考に設定した方が良さそです。 stackoverflow.com
djangoコマンド
startproject
- プロジェクトを作成する
$ python3.9 manage.py startproject myproj
dbshell
- データベースの接続確認と実際にDBに接続できる
$ python3.9 manage.py dbshell
migrage
- マイグレーションファイルをデータベースに反映
$ python3.9 manage.py migrate
createsuperuser
- 管理者サイトのためのスーパーユーザーを作成します。
$ python3.9 manage.py createsuperuser
startapp
- アプリケーション作成
$ python3.9 manage.py startapp accounts
makemigrations
- アプリケーションのmodels.py を探索してデータベースのマイグレーションファイルを作成します。
$ python3.9 manage.py startapp accounts
runserver
- サーバー起動
# python3.9 manage.py runserver 0:8000