2019年11月23日土曜日

2019年11月10日日曜日

【Django】Model定義周辺の小ネタ - Qiita

ウェブサイトを丸ごと保存するフリーソフトHTTrack - 知的好奇心

Django Admin ウィジェットテンプレートの上書き

Django2.2でAdminのテンプレートをプロジェクト直下に持ってきて編集していたのですが、ウィジェットに関してはテンプレートが上書き適用できなかった。

調べたところなかなかややこしいですが、以下の方法でできました。

1.前提として、プロジェクト直下のtemplateディレクトリにパッケージのテンプレートをコピーして上書き適用するには、 settigs.pyに以下の設定が必要です。
settigs.py

TEMPLATES = [
    {
       ・・・・・・
        'DIRS': [os.path.join(BASE_DIR, 'templates')], #★ここを変更
        'APP_DIRS': True,
       ・・・・・・  
    },
]

2.settings.pyに以下を追加する。

FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'

3.以下のような階層でdjango > forms > widgets ディレクトリを作りファイルをコピーする。

templates
├─admin
│  └─widgets
│          clearable_file_input.html #こちらのファイルを編集する
├─cms
├─django
│  └─forms
│      └─widgets
│              attrs.html
│              checkbox.html
│              checkbox_option.html
│              checkbox_select.html
│              clearable_file_input.html
                 #widgetsの中身を一式コピーしておく

とりあえずこれでOKでした。

参考:
Django、テンプレートファイルの探索順序について「ウィジェットテンプレートの上書き」
https://narito.ninja/blog/detail/135/  

2019年11月6日水曜日

Web API: The Good Partsを読んだまとめ - Qiita

python 組み込み関数を全て(69個)紹介する - Qiita

Vue.jsを習得するためにやった事 まとめ(随時更新) - Qiita

JavaScriptの配列操作

Windows10で2つのApacheが起動している

Windows10にApacheをインストールして、プロセスを確認してみるとApacheが2つあった。
おかしいなと思って調べてみるとWindowsではこれで大丈夫なようです。



Stackoverflow

Apache's documentation (https://httpd.apache.org/docs/2.4/platform/windows.html#page-header):

Because Apache for Windows is multithreaded, it does not use a separate process for each request, as Apache can on Unix. Instead there are usually only two Apache processes running: a parent process, and a child which handles the requests. Within the child process each request is handled by a separate thread.
https://stackoverflow.com/questions/40798483/why-apache-http-server-have-2-process-showing-on-task-manager