問い合わせフォームやユーザ登録フォームにて住所を入力させることがあるけれど、郵便番号を入力したら、住所が自動入力されるフォームを作ったのでメモです。 Djangoのフォームではモデルフォームを用いることがあるが、今回は個別アプリケーション内のforms.pyに記述する方法をとりました。 今回、住所自動入力のプラグインについてはajaxzip3を使用しました。 アプリケーション内にforms.pyを作成する アプリケーションディレクトリのforms.pyを作成し、以下を記述する。 from django import forms class TestForm(forms.Form): zip21 = forms.RegexField( regex=r'^[0-9]+$', max_length=3, ) zip22 = forms.RegexField( regex=r'^[0-9]+$',