- Vetur
- Auto Close Tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://kyam-013.hatenablog.jp/entry/2017/07/21/021106 | |
| from collections import defaultdict | |
| >>> s = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)] | |
| >>> d = defaultdict(list) | |
| >>> for k, v in s: | |
| ... d[k].append(v) | |
| ... | |
| >>> list(d.items()) | |
| [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import pandas as pd | |
| import itertools | |
| c = { | |
| # 条件:データパターン | |
| "条件A": ["あり", "なし"], | |
| "条件B": ["あり", "なし","空欄", "「*」"], | |
| "条件C": ["あり", "空欄", "「*」"], | |
| "条件D": ["あり", "なし", "空欄", "「*」"], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from アプリ名.models import モデル名 | |
| label=モデル名._meta.get_field('取りたいカラム名').verbose_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.shortcuts import render | |
| from django import forms | |
| from django.forms.models import modelformset_factory | |
| from django.db.models import Case, When, Value, FloatField | |
| # Create your views here. | |
| from .models import Post | |
| class PostForm(forms.ModelForm): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| label = Model定義._meta.get_field('フィールドの名前').verbose_name | |
| from django.db import models | |
| class Model定義(models.Model): | |
| フィールドの名前 = models.CharField(verbose_name='ラベルに表示したい名前') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django_tenants.test.cases import TenantTestCase | |
| from django_tenants.test.client import TenantClient | |
| from django.core.management import call_command | |
| class IndexPageTest(TenantTestCase): | |
| # ★これは読み込まれない | |
| # django-tenantsのsetUpClassがTestCase側のsetUpClassをコールしておらず、このfixturesを読むルートに入っていない | |
| fixtures = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # スーパーユーザー作る | |
| python manage.py tenant_command createsuperuser | |
| # ダンプ | |
| python manage.py tenant_command dumpdata --schema="schema-name" app_name.model_name --indent 2 > fixtures/hoge.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 下記のように、python.analysis.extraPathsで必要なモジュールをパス追加する | |
| { | |
| "folders": [ | |
| { | |
| "path": "django-tenants-diary" | |
| } | |
| ], | |
| "settings": { | |
| "editor.fontLigatures": null, | |
| "python.analysis.extraPaths": [ |