-
posts
-
Kubernetes Health Checks in Django
In a previous post I wrote about Kubernetes health checks. Since I’m a Python developer and a fan, I went about implementing it in Django. Health checks are a great way to help Kubernetes help your app to have high availability, and that include...
-
Django Girls Workshop Tokyoのコーチをやりました
先週末に Django Girls Workshop のコーチとして参加しました。Django Girls は Django ウェブフェレームワークの女性のための国際的なコミュニティ。東京のPyLadies と PyCon JP との協力で開催されました。私は実はコーチとしても、PyCon J...
-
Testing Django Views Without Using the Test Client
The normal way to test Django views is via the test client. The test client fakes being a wsgi server and actually makes an HTTP request through all of Django’s request routing machinery. There are a number of reasons why this isn’t an ideal appro...
-
require.js + Django 設定の組み合わせ
JavaScriptをよく書いている場合、普通のアプリケーションと同じように設定を
書きたい場合があると思う。たとえば、開発の場合によく DEBUG フラグとか設定するよね?
たとえば、 Djangoを使っている場合、 settings.DEBUG が True と時に、JavaScriptに...
-
Django で Amazon SES を使う
Amazon さんが、Amazon Web Services の下にメール送信サービス Simple Email Service
(SES) を
提供している。このサービスは、主に大量なメールでも正しく送信して、
メールがちゃんと届くようにサービスを提供している。
connpass ではメー...
-
Django 1.5.1 のリリース (ジェネレーターに例外処理はダメ?)
Django 1.5.1 が昨日
リリースされました
。リリース内容を見るて、クエリーセットにメモリリークの問題があったそうです。
もともとのバグ
1.4 では、2回クエリーセットを解決すると、空な結果が返ってきて、前の結果がガーベージコレクションされない現象があったそうです (バグ
#1...
-
Administer WordPress using Django's Admin
I recently came across one feature of Django that seemed pretty useful
for one off projects and customizations and was startled because it’s
one of Django’s least mentioned features. In fact, I’ve been using
Django at work for over 5 years now and...
-
Django 1.5 の紹介
この記事は 2012
Pythonアドベントカレンダー(Webフレームワーク)
の第3目の記事。昨日の記事は id:shomah4a の「 2012 Python アドベントカレンダー (Web フレームワーク ) 二日目
WSGI でなんか作ってみる 」。明日は surgo
さんが...
-
Djangoの DateTimeField の auto_now と auto_now_add
Django の Model の DateTimeField に auto_nowと auto_now_add
というキーワード引数があります。この引数はデフォールトで False になっていますが、
True にすると、 モデルのインスタンスを保存するタイミングで更新されます。
auto_n...
-
Django's contrib.auth and django-newauth
Recently there have been a lot of conversations on the Django mailing
list about fixing the auth module. Here are some of the recent mailing
list threads:
authentication by
email
auth.User refactor:
reboot
auth.User: The abstract base clas...
-
Django 1.3.1 セキュリティリリース
先週の金曜日に Django 1.2.7 と Django 1.3.1
のセキュリティリリース
がリリースされました。
いくつかのセキュリティ問題が 1.2 と 1.3 系の Django にありました。なるべく早くアップデートすることをおすすめします。
僕の会社の AE35 さん リリー...
-
bpssl - The Django SSL Support Application
The other day I released bpssl which is a Django application that helps
you support HTTPS on your website. The main functionality is performing
redirection for HTTPS only URLs and views. For instance, if a request
for your login view ‘/login’ is r...
-
bpssl のDjango SSL対応アプリをリリースしました
今日、 bpssl をリリースしました。bpsslは BeProud で欲使っている
Django用のSSL対応アプリです。 アクセスする時にHTTPSが必須なURLを指定することがよくありますよね? 例えば、
ログイン画面をHTTPSでしかアクセスできないようにする。ただし、 HTTPでアク...
-
Djangoを主に使っているgumi がGREEから数億円の調達に成功した感想
僕の会社BeProud のもう一つの主に Django を使っている会社は gumi. グミはもともと
酒徳さん が作った Django サイトで、明らかに有名になってきた。昨日、
Gree から数億円の調達に成功したというニュースが出た。
酒徳さんはもう別の会社 Unoh
ラボ
に戻っ...
-
Django ドキュメント翻訳スプリント
Django の日本語ドキュメントの翻訳が 1.0~1.1 の間のままで、Django 1.3
が年末にそろそろ出るということで、かなり遅れています。
ということで、 11月の19日~21日のPython 温泉でDjango ドキュメント編訳スプリントを行います。Django
に興味ある方は...
-
BPStudy #37
昨日、BPStudyで、 Djangoアプリの実践的設計手法について発表をしました。
スライドをSlideshare にアップした。
Djangoアプリの実践的設計手法</embed>View more presentations from Ian Lewis.
-
特定なDjangoモデルを別DBに保存するメモ
今日、会社で特定なDjangoモデルを別のDBに保存するようなニーズがあって、Django マルチDBを使えるかなという話がありました。
この間、
Django1.2のマルチDBはレプリケーション対応に微妙
っブログに書きましたけど、ModelでDBを使い分けるのができるはずと思って、DBルー...
-
Django アプリサーバ、gunicorn と fastcgi の比較
概要
最近、会社では、fastcgi より、 gunicorn を使うのがどう?
といわれました。gunicorn を触ったことない僕は fastcgi
のロードテストも実際やったことなくて、メソッドについて、(prefork
がいいか、 threadedがいいか) の読んでいたものを元...
-
Python 温泉 (夏 2010)
Python 温泉 in 熱海に行ってきました。ま、まだ熱海の旅館なんだけど、早速 Blog を書こうと思っていました。
結構いい感じで、進んで来ました。会社の AE35 、 と
akisutesama と電車に乗ってきました。電車の中、ずっと
iPhone 触りつつ
増田さん が...
-
Python StringIO と cStringIO のもう一つの違い
C で作られた cStringIO は ピュア Python で作られた StringIO
モジュールと違うのをみんな知っていると思いますけど、今日、私が知らなかった違いをもう一つ見つけました。
StringIO では、StringIO のコンストラクターに文字列を渡せば、その文字列に書き込...
-
Django 1.2 マルチ DB と master/slave レプリ
Django 1.2 はマルチDB対応ができまして、master/slave
レプリにも対応しているのですが、詳しく見るといろな問題が出てきます。
Django 1.2 のマルチDB対応は
どのDBから、読み込むか、どのDBに書き込むかがDBルータで決める。しかし、そのルータで決める時点でリ...
-
Django 1.2 の変更のまとめ
先週、 Django 1.2 が出ました。新しくて、良い機能がいっぱい入っているけども、1.1 からの変更をご紹介しようかと思っています。
マルチDB
1.2 では、一番大きい変更は明らかに
マルチDB対応
ですね。 settings.py の DATABASE オプションは DATABA...
-
'self' ForeignKeys always result in a JOIN
I came across a little annoyance in Django today. I found that
ForeignKeys that reference ‘self’, i.e. they point to the same table,
always result in a join in a filter.
Take this normal foreign key reference.
class Customer(models.Models):
...
-
Django template2pdf
This is cool Django application from Yasushi
Masuda which allows you to render data to
a pdf using trml2pdf.
template2pdf provides a
generic view called direct_to_pdf which will render a rml template
directly to pdf.
# coding: utf-8
from django...
-
Django modelformset_factory便利
Django
は複数のフォームのデータを同時に扱えるために、FormSetsというものを用意しているんですけど、実は、ModelFormのFormSetでも使える。クエリーの結果のデータのModelFormを一個一個、一つのページに出すにはこんなコードを書ける。
from django.fo...
-
daemontoolsを使ってdjango fastcgiのデーモンを設定する
daemontoolsの上にdjango
fastcgiを使うのは簡単にできるけど、正しいユーザとして、フォアグラウンドに起動するにはbashとdaemontoolsの設定する必要がある。
フォアグラウンドに起動するには、daemonize=falseを指定する必要がある。
それで、起動す...
-
Running django with daemontools
Running django fastcgi with daemontools is rather easy but getting it to
run in the foreground with the proper user takes a bit of knowledge
about how bash works and the tools in daemontools.
In order to run the fastcgi daemon in the foreground y...
-
Testing HTTPS with Django's Development Server
Django’s development server doesn’t normally support HTTPS so it’s hard
to test applications with HTTPS without deploying the application to a
real web server that supports HTTPS. The secret is to use two
development server instances, one for http...
-
DjangoのHTTPS対応開発サーバ
Djangoの開発サーバはHTTPSを普段に対応してないので、HTTPS対応をどうやって開発すればいいんだろうと思ったら、調べてみた。秘密は開発サーバ、http用とhttps用を二つ立ち上げます。https開発サーバはstunnelでHTTPS対応します。stunnelは普通のソケットをSSL...
-
Minimum cost for warming-up various frameworks(and more)
My good friend Takashi Matsuo
wrote an interesting blog about start up times of various frameworks on
appengine. Because appengine kills your server process it often needs to
load your application into memory from scratch. This can take a lot of
t...
-
Testing using a mocked HTTP server
Recently I got some tests working for my
django-lifestream
project. The lifestream imports data from RSS/Atom feeds so there isn’t
a good way to run tests without creating a test HTTP server to serve up
your RSS/Atom.
The tests start up an http s...
-
Django redirect_to はnon-ascii URLに対応してない
Django は一般的なリダイレクトするビューを django.views.generic.simple.redirect_to
に用意していますけど、unicodeのキーワードがあれば、動かないのが最近見つけた。
Djangoプロジェクトのurls.pyでこういう風にURLの設定を書けます...
-
Annoying things about Django
Since I’ve been using it for a while now I’ve gotten a good idea about
what is good and what is annoying about development with django. This
might seem a little trite at parts since some of these gripes are with
features that don’t exist in other ...
-
Custom Admin Views and Reversing Django Admin URLs
I recently used the new feature in Django 1.1 for reversing django
admin
urls
and specifying custom admin
views
in my project
django-lifestream.
django-lifestream has a custom admin
view
which allows users to update the lifestream manually. The c...
-
Django and nginx settings
One problem I keep encountering with setting up fastcgi with Django is
that the default nginx fastcgi parameters cause django to load the top
url no matter what url you try to go to. This is because the default
nginx fastcgi parameters pass the SC...
-
明日からPython温泉
明日からPython温泉に参加しに行ってきます。課題は下記のとおり
django-lifestream
の整理
disqus-api-client
の実装
homepage のバグを直す
Appengine
上のコードスニペットのウェブサイトのまとめ
Google An...
-
Google Appengine SDK 1.2.3
The Google Appengine
SDK 1.2.3
was just released and contains some often asked for goodies such as
Django 1.0 support and support for a task queue
API.
I haven’t found much information about the Django 1.0 version in
Appengine but here are some l...
-
Preview blog posts within the django admin.
I
implemented
blog post previews for my blog using the technique described here:
http://latherrinserepeat.org/2008/7/28/stupid-simple-django-admin-previews/
It’s very simple as it is simply a view using an existing record. I’d
prefer something th...
-
New Django-based Homepage
I finally got around to finishing up my
Django based website. It’s pretty
inexcusable for a Django developer to have a PHP based blog website. I’m
happy that it seems to be snappier and I haven’t don’t anything
particular to try to make it fast so...
-
Python 例外のひどい仕様
Pythonの例外オブジェクトは苦手です。例外のメッセージが何でもasciiとして扱われることがひどい。
In [1]: t = ValueError("テスト".decode("utf8"))In ...
-
Django 勉強会 Disc. 8 参加して来た
。。というか、ハンズオンC Django on
GAE
のセッションを担当させていただきました。まさかこんなに人気があると思わなかったけど、皆さんはびっくりするほど勢いを持ってきて、感動しました。
Pollsというアプリを動かすまで出来た人がほとんどで、すごくうれしい思い出ができました。
...
-
Django勉強会Disc.8の資料をRSTにした
id:tokibitoが見つけてくれた rst2pdf を使ってid:tmatsuo とDjango勉強会Disc.8 ハンズオンC の資料をPDFにした。
ほとんど id:tokibitoと同じやり方でPDFを吐き出したけど、問題点が二つあった。
rst2pdf をたたくと ja.jso...
-
Werkzeug and reverse urls
I wanted to impove a Google Appengine application that a friend of mine created (ほぼ汎用イベント管理ツール(jp)) and noticed that he was redirecting directly to urls. He is using Werkzeug to handle url routing so I wondered if there was a method for generating...
-
Werkzeugのreverse URL処理
ほぼ汎用イベント管理ツールの改善をしようと思ってて、実際にコードを見るとURLを使ってるのが気になった。
WerkzeugのURLルーティングでDjangoのreverse関数みたいにURLの名前からURLに変換できるのかなと調べて、ある方法がありました。名前からじゃなくて、endpoint...
-
QueryDict and update()
Yesterday I ran into an interesting quirk with Django's QueryDict object and the normal dictionary update() method. Normally the update method will allow you to merge two dictionary or dictionary like objects but because the QueryDict internally h...
-
Field/column Queries in Django
One of the neat things making it's way into Django 1.1 is F object queries. The F object is kind of like the Q object as it can be used it queries but it represents a database field on the right hand side of an equality/inequality.
For the exampl...
-
Google Appengine SDK 1.1.8がリリースされました
Appengineの新しいリリース1.1.8が来た。色な面白いところがあるけど、仲居さん(id:Voluntas)のブログポストからピックアップする。
ByteStringProperty が実装 気軽に使える BlobProperty
UserProperty に auto_curre...
-
Django 勉強会 Disc.7
昨日、アクセンス・テクノロジーの東京本社にDjango 勉強会 Disc.7に参加しに行ってきました。
GeoDjango
最初は松尾さんのgeodjangoの話。
GeoDjangoのDBサポートはpostgisが一番対応してます。
Adminで地形のエリア編集などは地図のJavascr...
-
Django サイトマップ フレームワーク
Django sitemap frameworkを使うのが簡単過ぎる。下記のようにサイトマップクラスを作って、urls.pyに登録するだけ。サイトマップに載るURLを取るのに、サイトマップフレームワークが自分が作ったクラスのitems()を呼び出して、アイテムのget_absolute_url...
-
Django Sitemap Framework
Using the Django sitemap framework is so easy it's almost no work at all. Just make a sitemap object and add it to the sitemap in urls.py. The sitemap framework calls items() in your Sitemap to get the list of objects to put in the sitemap and the...
-
Django admin inline forms
For my new project dlife (Update: Now django-lifestream), I went about implementing a simple comments interface that would allow users to make comments on imported feed items. I wanted to support this in the admin in the typical manner such that w...
-
DjangoGraphviz
今日、Djangoアプリケーションのモデルの構成を分かりやすく見たくて、モデル構成からGraphviz ドットファイルを生成できれば、いいなと思って、DjangoGraphvizを見つけた。ただ、ここからダウンロードして、こう実行する。
PYTHONPATH=$PYTHONPATH:. DJA...
-
初出勤日
新しい会社に入って、初出勤日が無事に終了しました。結構いい感じでした。前の会社では、狭いとこに住み、残業してたりしてて、電車が込んでて、二年間結構苦しんで仕事してたんです。今はもう広いマンションで住んでて、会社の人がゆっくりで仕事してて、電車も空いてて、PythonとDjangoで仕事できて、...
-
Python Onsen Oct. 2008
Last weekend I went to my second Python Onsen[jp] organized by Nakai-san(id:voluntas). I talked about Python Onsen in my first blog post here. Python Onsen is a 3 day event (Fri, Sat, Sun) but as before I only participated on Saturday and Sunday. ...
-
Python温泉
先週末、 Python温泉第4回に行ってきました。Python温泉は金土日なんですけど、前回と同じく土日、1泊にやってきました。今回は集中できたけど、前回より友達つくりや、会話ができてなかったという感覚だった。いろいろ寂しかった。でも、ビープラウドのid:tokibitoさんと、jQuery...
-
ウェブホスティング移動
最近PythonやDjangoの開発をだんだんやっていてる僕が、このサイトを新しいウェブホスティングプロバイダーに移動することにした。 今は Haswebという安いプロバイダーなんですけど、Pythonにあまり相性がよくないので、Pythonアプリをサーバーに動かすのが難しすぎる。 簡単なPy...
-
Django
I was thinking about using Django for one of my projects on GAE because it seems like a popular project and somewhat easy to use, but I'm not quite understanding yet why it's better to have helper functions rather than controller/handler classes l...