ytyng.com

新着記事

Page 13
Django
2017-01-26 04:11 (9 years ago)

けっこう何回もミスってしまうのでメモ。

AWSMySQL
2017-01-03 12:34 (9 years ago)

AWS RDS MySQL のレプリケーションの様子がおかしい MyIsam テーブルがありますが、 CHECK TABLE xxxx_xxxx; してみると Table    Op    Msg_type    Msg_text xxxx.xxxx_xxxx    check    error    Corrupt Msg_text が Corrupt。このテーブルは腐ってると言われます。マスターの方は問題無し。 AWS コンソールの RDS ページを見てみると レプリケーションが失敗している SHOW SLAVE STATUS を見ると {

DjangoLinux
2016-09-16 03:24 (9 years ago)

元々はAWS ELB -> Apache2 -> mod_wsgi という構成だったが、AWS ELB -> Apache2 -> uwsgi と、Djangoサーバを uwsgi に変えたら、ログインフォームを送信する時など、django csrf 認証に失敗するようになった。DEBUG = True で見てみるとアクセス禁止 (403)CSRF検証に失敗したため、リクエストは中断されました。HelpReason given for failure:    Referer checking failed - https://example.com.com/some-path/ does not match any trusted origins.    In general, this can occur when there is a genuine Cross Site Request Forgery, or when Django's CSRF mechanism has not been used correctly. For POST forms, you need to ensure:    Your browser is accepting cookies.    The view function passes a request to the template's render method.    In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL.    If you are not using CsrfViewMiddleware, then you must use csrf_protect on any views that use the csrf_token template tag, as well as those that accept the POST data.You're seeing the help section of this page because you have DEBUG = True in your Django settings file. Change that to False, and only the initial error message will be displayed.You can customize this page using the CSRF_FAILURE_VIEW setting.ELB で HTTPS を受け、Apache には 80 でリクエスト、uwsgi は HTTP プロトコルをリッスンしている(uwsgiプロトコルではない)Apacheの設定はProxyPass / http://127.0.0.1:8081/ProxyPassReverse / http://127.0.0.1:8081/Alias /static/ /var/django/xxxxx/staticfiles/ProxyPass /static/ !こんな感じ。Django のコードを検索してみるとcsrf.pyREASON_BAD_REFERER = "Referer checking failed - %s does not match any trusted origins."こうなっていて、コードを読んで見ると CSRF_TRUSTED_ORIGINS にドメインを入れれば良いっぽい。CSRF_TRUSTED_ORIGINS = [".example.com"] これで良い

2016-09-14 09:50 (9 years ago)

ブログのコメントシステムに Disqus を使ってる場合

MySQL
2016-09-14 09:44 (9 years ago)

まったく定量的な話でないのですが。

DjangoPython
2016-06-20 08:35 (9 years ago)

Python 3, Django 1.9

mac
2016-01-02 14:35 (10 years ago)

mac 10.11 El Capitan で、ダウンロードした Steam を起動しようとしたら「アプリケーション"Steam.app"を開けません。」というエラーが出て起動できなかった場合。

Django
2015-12-22 09:57 (10 years ago)

/url-path-before/feature/hoge/ にアクセスした人を、 /url-path-after/feature/hoge/ にリダイレクトしたい。

iOS
2015-12-21 06:37 (10 years ago)

iOSアプリのビルド時 duplicate symbol _OBJC_CLASS_ が大量に出て焦った時

HTML
2015-12-02 09:32 (10 years ago)

WebFont を使っていると、フォントが読み込まれないと文字が表示されない FOUT という現象が発生する。

MySQL
2015-12-01 06:42 (10 years ago)

経緯 MySQL5.6 の、InnoDB にバイグラムでフルテキストインデックスを作っているのですが、 TWIN という文字を検索しようとした所、

Python
2015-12-01 02:02 (10 years ago)

SSL証明書の有効期限を timedelta で取得

iOS
2015-11-05 11:27 (10 years ago)

下記記事が参考になりました。

Django
2015-10-29 08:35 (10 years ago)

Django に標準搭載の django.views.generic.TemplateView。

Bootstrap
2015-10-27 09:35 (10 years ago)

Bootstrap で、ヒーローエリアの大カルーセルを表示する時、初期位置をランダムで変更する方法です。

Python
2015-10-19 07:34 (10 years ago)

今までは、threading.Thread を使ってオレオレスレッドプールなんかを書いてたりしましたが、Pythonに用意されてないはずがないと思って探してみたら multiprosessing.pool.Pool がそれでした。超簡単にプロセスプールが作れる。今までの俺は何だったんだ。

Python
2015-10-16 07:35 (10 years ago)

multiprocessing.pool.Pool 使えばよかった orz

Django
2015-10-15 10:10 (10 years ago)

class Content(models.Model): content_name = models.Charfield(...) group_id = models.PositiveIntegerField(...) volume_number = models.PositiveIntegerField(...) ... 典型的な Django のモデルクラスががあるとして、そのインスタンスを複雑な SQL 1発で検索したい。 結果は Web ページに表示したいが、多くの行になることが予想されるため、パジネータを表示したい。