LoginSignup
0
0

More than 3 years have passed since last update.

Django Botstrapからのテンプレート登録

Last updated at Posted at 2020-03-08

■環境

 windows10
 Pycharm Community 2019.3
 Python3.7
 Django3.03

■前提条件

 Djangoプロジェクト、アプリケーション作成していることを前提。以下参照
 ターミナルでDjangoアプリケーション作成まで

 アプリケーション作成後、以下で登録
 アプリケーションの登録

■できること

 Bootstrap の無料テンプレートをDjangoで利用

■手順

① Bootstrapテンプレートのダウンロード

 https://startbootstrap.com/

 のThemaからテンプレート選択し、ダウンロード。

② Djangoプロジェクトにコピーする。

 1)Djangoプロジェクト直下に、staticディレクトリ作成

 2)そこに、「css」「imag」「vender」のみコピーする
 
 image.png

コピー後のディレクトリ構造
image.png

③ 静的ファイルの配置場所を設定する。

このままでは、Djangoは配下ファイルの場所が把握できないので、
場所を、setting.pyに以下追加する。

STATICFILES_DIRS = (
    os.path.join(BASE_DIR,'static'),
)

 BASE_DIR は、Setting.pyの中で以下のように絶対パスで定義されている。

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

以上

 

 

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0