{"title":"Django への初めてのパッチを書く","version":"1.9","locale":"ja","docname":"intro/contributing","url":"/ja/1.9/intro/contributing/","canonical":"https://djangodocs.dev/ja/1.9/intro/contributing/","summary":"少しでもコミュニティへ恩返しをしたいと思われますか? それは Django の簡単なバグフィックスや小さな機能追加かもしれません。","html":"<h1>Django への初めてのパッチを書く<a class=\"heading-anchor\" href=\"#writing-your-first-patch-for-django\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<section id=\"introduction\">\n<h2>はじめに<a class=\"heading-anchor\" href=\"#introduction\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>少しでもコミュニティへ恩返しをしたいと思われますか? それは Django の簡単なバグフィックスや小さな機能追加かもしれません。</p>\n<p>その願いを叶える最適な方法は Django 自体への貢献です。最初は気が重いかもしれませんが、実際はとても簡単です。私達がプロセス全体を詳しく解説するので、その例から学ぶことができるでしょう。</p>\n<section id=\"who-s-this-tutorial-for\">\n<h3>このチュートリアルは誰を対象としていますか?<a class=\"heading-anchor\" href=\"#who-s-this-tutorial-for\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<aside class=\"admonition admonition-seealso\" role=\"note\">\n<p class=\"admonition-title\">参考</p>\n<p>パッチの送り方について知りたい方は、 <a class=\"reference internal\" href=\"/ja/1.9/internals/contributing/writing-code/submitting-patches/\"><span class=\"doc\">Submitting patches</span></a> をご覧ください。</p>\n</aside>\n<p>このチュートリアルは、少なくとも Django がどのように動作しているかの基本的な理解があることを想定しています。つまりチュートリアル <a class=\"reference internal\" href=\"/ja/1.9/intro/tutorial01/\"><span class=\"doc\">初めての Django アプリ</span></a> を十分に理解していることを想定しています。また、Python 自体をよく理解している必要があります。もしそうでない場合、 <a class=\"reference external\" href=\"http://www.diveintopython3.net/\">Dive Into Python</a> は Python プログラマーになるための素晴らしい (かつ無料の) オンラインドキュメントです。</p>\n<p>バージョン管理システムと Trac をよく知らない方でも、このチュートリアルとリンク先から、始めるに十分な情報を得ることができます。しかし、Django に定期的に貢献したい場合は、このツールの詳細について知りたいかもしれません。</p>\n<p>このチュートリアルでは、できるだけ多くの方が使用できるように可能な限り解説したいと思います。</p>\n<aside class=\"admonition-where-to-get-help admonition\" role=\"note\">\n<p class=\"admonition-title\">困ったときは:</p>\n<p>もしこのチュートリアルを通じて理解できないことがあれば、 <a class=\"reference internal\" href=\"/ja/1.9/internals/mailing-lists/#django-developers-mailing-list\"><span class=\"std std-ref\">django-developers</span></a> にメッセージを送るか <a class=\"reference external\" href=\"irc://irc.freenode.net/django-dev\">#django-dev on irc.freenode.net</a> で他の Django ユーザーとのチャットが助けになるでしょう。</p>\n</aside>\n</section>\n<section id=\"what-does-this-tutorial-cover\">\n<h3>このチュートリアルの範囲はなんですか?<a class=\"heading-anchor\" href=\"#what-does-this-tutorial-cover\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>初めて Django にパッチを送る手順を詳しく解説します。このチュートリアルを終えると、関連するツールとプロセス両方についての基本的な理解を得ることができます。具体的な範囲は以下の通りです:</p>\n<ul class=\"simple\">\n<li><p>Git のインストール</p></li>\n<li><p>開発版の Django の複製をダウンロード</p></li>\n<li><p>Django のテストスイートの実行</p></li>\n<li><p>パッチへのテストを書く</p></li>\n<li><p>パッチのコードを書く</p></li>\n<li><p>パッチをテスト</p></li>\n<li><p>変更のパッチファイルを生成</p></li>\n<li><p>より多くの情報を得る方法</p></li>\n</ul>\n<p>チュートリアルを終えたら、次は <a class=\"reference internal\" href=\"/ja/1.9/internals/contributing/\"><span class=\"doc\">Django への貢献</span></a> を参照してください。このドキュメントには、多くの重要な情報が含まれており、Django に定期的に貢献したい方は是非一読してください。あなたの疑問への答えが見つかるはずです。</p>\n<aside class=\"admonition-python-3-required admonition\" role=\"note\">\n<p class=\"admonition-title\">3系の Python が必要です！</p>\n<p>このチュートリアルは3系のPythonの使用を想定しています。 <a class=\"reference external\" href=\"https://www.python.org/download/\">Python's download page</a> またはOSのパッケージ管理システムを用いて、最新のバージョンをインストールしてください。</p>\n</aside>\n<aside class=\"admonition-for-windows-users admonition\" role=\"note\">\n<p class=\"admonition-title\">Windowsを使用している方へ</p>\n<p>WindowsにPythonをインストールする際、 &quot;Add python.exe to Path&quot; のオプションにチェックを入れると、コマンドラインからいつでも利用できるようになります。</p>\n</aside>\n</section>\n</section>\n<section id=\"code-of-conduct\">\n<h2>ソースコードの管理<a class=\"heading-anchor\" href=\"#code-of-conduct\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>あなたはコントリビューターとして私たちDjangoコミュニティをオープンかつ包摂的なものでありつづけることを援助できます。私たちの ソースコードの管理 &lt;https://www.djangoproject.com/conduct/&gt; を参照し、フォローして下さい。</p>\n</section>\n<section id=\"installing-git\">\n<h2>Git のインストール<a class=\"heading-anchor\" href=\"#installing-git\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>このチュートリアルでは、最新の Django 開発版のダウンロードとその変更のパッチファイルを生成するために Git をインストールする必要があります。</p>\n<p>Git がインストールされているかどうかを確認するために、コマンドラインで <code class=\"docutils literal notranslate\">git</code> を入力します。もし入っていない場合は、ダウンロード及びインストールするために、 <a class=\"reference external\" href=\"http://git-scm.com/download\">Git's download page</a> を参照してください。</p>\n<aside class=\"admonition-for-windows-users admonition\" role=\"note\">\n<p class=\"admonition-title\">Windowsを使用している方へ</p>\n<p>WindowsにGitをインストールする際、 &quot;Git Bash&quot; オプションを選択し、シェルからGitが操作できるようにしておくことをおすすめします。このチュートリアルは Git Bash がインストールされていることを想定しています。</p>\n</aside>\n<p>もし Git について詳しく知らない場合は、(インストール後に) コマンドラインから <code class=\"docutils literal notranslate\">git help</code> と入力するとコマンドの使い方を確認できます。</p>\n</section>\n<section id=\"getting-a-copy-of-django-s-development-version\">\n<h2>Django 開発版の複製を取得<a class=\"heading-anchor\" href=\"#getting-a-copy-of-django-s-development-version\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django への貢献の第一歩はソースコードの複製の取得から始まります。コマンドラインで、 <code class=\"docutils literal notranslate\">cd</code> コマンドを使い、Django をローカルに複製するディレクトリに移動します。</p>\n<p>以下のコマンドで Django のソースコードリポジトリをダウンロードします:</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>git clone https://github.com/django/django.git\n</code></pre></div>\n<p>今やあなたはDjangoのローカルコピーを手に入れました、&quot;pip&quot;を使ってどんなパッケージでもインストールできるのと同じように、Djangoもインストールできます。Pythonに含まれる機能である <em>virtual environment</em> (もしくはvirtualenv)は、プロジェクトごとにインストールされたパッケージが互いに害を及ぼすことないよう、別々のディレクトリで維持することを可能にする、もっとも便利な方法です。</p>\n<p>ホームディレクトリの <code class=\"docutils literal notranslate\">.virtualenvs/</code> 以下に、すべてのvirtualenvを 1 箇所においておくといいです。もしまだそのフォルダが存在しないなら作成しましょう。</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>mkdir ~/.virtualenvs\n</code></pre></div>\n<p>それではアプリケーションを実行するために新しいvirtualenvを作りましょう:</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>python3 -m venv ~/.virtualenvs/djangodev\n</code></pre></div>\n<p>新しい環境があるパスはコンピュータに保存されました。</p>\n<aside class=\"admonition-for-windows-users admonition\" role=\"note\">\n<p class=\"admonition-title\">Windowsを使用している方へ</p>\n<p>ビルトインの <code class=\"docutils literal notranslate\">venv</code> は、 Windows 用にはシステムシェル(<code class=\"docutils literal notranslate\">.bat</code>) やPowerShell(<code class=\"docutils literal notranslate\">.ps1</code>)のためだけに作られたアクティベーションスクリプトであるため、WindowsのGit Bash shellを使用していても動作しません。その代わりに``virtualenv``パッケージを使用します:</p>\n<div class=\"code-block\" data-language=\"none\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">None</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"None code\"><code>$ pip install virtualenv\n$ virtualenv ~/.virtualenvs/djangodev\n</code></pre></div>\n</aside>\n<aside class=\"admonition-for-ubuntu-users admonition\" role=\"note\">\n<p class=\"admonition-title\">Ubuntuを使用している方へ</p>\n<p>いくつかのバージョンのUbuntuでは上記のコマンドは失敗するでしょう。まず <code class=\"docutils literal notranslate\">pip3</code> があることを確認し、 <code class=\"docutils literal notranslate\">virtualenv</code> パッケージを使用します。</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>sudo apt-get install python3-pip\n<span class=\"gp\">$ </span><span class=\"c1\"># Prefix the next command with sudo if it gives a permission denied error</span>\n<span class=\"gp\">$ </span>pip3 install virtualenv\n<span class=\"gp\">$ </span>virtualenv --python<span class=\"o\">=</span><span class=\"sb\">`</span>which python3<span class=\"sb\">`</span> ~/.virtualenvs/djangodev\n</code></pre></div>\n</aside>\n<p>virtualenvを有効化すれば設定は終わりです:</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span><span class=\"nb\">source</span> ~/.virtualenvs/djangodev/bin/activate\n</code></pre></div>\n<p>もし <code class=\"docutils literal notranslate\">source</code> コマンドが使えない場合、代わりに <code class=\"docutils literal notranslate\">.</code> を試してみてください:</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>. ~/.virtualenvs/djangodev/bin/activate\n</code></pre></div>\n<aside class=\"admonition-for-windows-users admonition\" role=\"note\">\n<p class=\"admonition-title\">Windowsを使用している方へ</p>\n<p>Windows上でvirtualenvを有効にするために、実行してください:</p>\n<div class=\"code-block\" data-language=\"none\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">None</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"None code\"><code>$ source ~/virtualenvs/djangodev/Scripts/activate\n</code></pre></div>\n</aside>\n<p>ターミナルの新しいウィンドウを開いたときは、virtualenvを有効にする必要があります。 <a class=\"reference external\" href=\"https://virtualenvwrapper.readthedocs.io/en/latest/\">virtualenvwrapper</a> はこれをより簡単にできるツールです。</p>\n<p>これより <code class=\"docutils literal notranslate\">pip</code> を通じてインストールした何もかもが、他の環境やシステムワイドなパッケージから分離されて、新しいvirtualenvにインストールされます。また、どの環境を使っているのかがわかるように現在有効なvirtualenvの名前がコマンドラインに表示されます。先ほどクローンしたDjangoのコピーをインストールして作業を続行します:</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>pip install -e /path/to/your/local/clone/django/\n</code></pre></div>\n<p>現在インストールされたDjangoはあなたのローカルコピーを参照しています。あなたが行ったどのような変更も迅速に確認できます、これはあなたが最初のパッチを作成するときの大きな助けになります。</p>\n</section>\n<section id=\"rolling-back-to-a-previous-revision-of-django\">\n<h2>旧リビジョンの Django に戻す<a class=\"heading-anchor\" href=\"#rolling-back-to-a-previous-revision-of-django\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>このチュートリアルでは、ケーススタディとして <a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/24788\">#24788</a> を用います。そのために、まず Django のバージョンをパッチが適用される前の git のバージョンに戻します。これによりスクラッチからパッチの作成、 Django のテストスイートの実行を含む全ての手順を解説します。</p>\n<p><strong>チュートリアルでは trunk ではない古いリビジョンの Django を使用しますが、自分のパッチを作成する場合は Django の最新の開発版を使用する必要があります!</strong></p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">注釈</p>\n<p>このチケットのパッチは Paweł Marczewski 氏により書かれ、これは <a class=\"reference external\" href=\"https://github.com/django/django/commit/4df7e8483b2679fc1cba3410f08960bac6f51115\">commit 4df7e8483b2679fc1cba3410f08960bac6f51115</a> で Django に適用されました。よって <a class=\"reference external\" href=\"https://github.com/django/django/commit/4ccfc4439a7add24f8db4ef3960d02ef8ae09887\">commit 4ccfc4439a7add24f8db4ef3960d02ef8ae09887</a> が適用される前の Django のリビジョンを使用します。</p>\n</aside>\n<p>Django のルートディレクトリ (このディレクトリには <code class=\"docutils literal notranslate\">django</code>, <code class=\"docutils literal notranslate\">docs</code>, <code class=\"docutils literal notranslate\">tests</code>, <code class=\"docutils literal notranslate\">AUTHORS</code>, 等が含まれています) へ移動します。次にチュートリアルで使用する Django の旧リビジョンをチェックアウトします。</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>git checkout 4ccfc4439a7add24f8db4ef3960d02ef8ae09887\n</code></pre></div>\n</section>\n<section id=\"running-django-s-test-suite-for-the-first-time\">\n<h2>最初に Django のテストスイートを実行する<a class=\"heading-anchor\" href=\"#running-django-s-test-suite-for-the-first-time\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django へ貢献する際、変更したコードが Django の他の領域にバグを混入しないことが非常に重要です。変更後に Django の正常動作を確認するには Django のテストスイートを実行します。すべてのテストに合格した場合は、その変更により Django が壊れていないことが確認できます。Django のテストスイートを実行したことが一度もない場合、その出力結果を把握しておくために一度テストスイートを実行しておくことを推奨します。</p>\n<p>Django のテストスイートを走らせる前に、まずは Djangoの <code class=\"docutils literal notranslate\">tests/</code> ディレクトリに <code class=\"docutils literal notranslate\">cd</code> で移動して、依存関係をインストールしてください:</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>pip install -r requirements/py3.txt\n</code></pre></div>\n<p>テストスイートを実効する準備が出来ました。もし GNU/Linux, Mac OS X 等 Unix 系OSを使用している場合、下記のコマンドを実行します:</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>./runtests.py\n</code></pre></div>\n<p>それでは一息つきましょう。Django 全体のテストスイートは 9600 以上のテストが含まれており、コンピュータの速度により 5 〜 15分程度かかります。</p>\n<p>Django のテストスイートを実行中に、各テストの状態を文字のストリームで確認することができます。 <code class=\"docutils literal notranslate\">E</code> はテストにエラーが発生したことを表し、 <code class=\"docutils literal notranslate\">F</code> はテストのアサーションが失敗したことを表しています。これらは共にテスト失敗となります。<code class=\"docutils literal notranslate\">x</code> と <code class=\"docutils literal notranslate\">s</code> はそれぞれ期待する失敗とスキップを表しています。ドットはテストの成功を表しています。</p>\n<p>スキップされたテストは、テストを実行するために必要な外部ライブラリがインストールされていないことが原因です; 依存については <a class=\"reference internal\" href=\"/ja/1.9/internals/contributing/writing-code/unit-tests/#running-unit-tests-dependencies\"><span class=\"std std-ref\">Running all the tests</span></a> を参照し、関連するテストを実行してください (このチュートリアルでは必要ありません)。</p>\n<p>Once the tests complete, you should be greeted with a message informing you\nwhether the test suite passed or failed. Since you haven't yet made any changes\nto Django's code, the entire test suite <strong>should</strong> pass. If you get failures or\nerrors make sure you've followed all of the previous steps properly. See\n<a class=\"reference internal\" href=\"/ja/1.9/internals/contributing/writing-code/unit-tests/#running-unit-tests\"><span class=\"std std-ref\">Running the unit tests</span></a> for more information. If you're using Python 3.5+,\nthere will be a couple failures related to deprecation warnings that you can\nignore. These failures have since been fixed in Django.</p>\n<p>開発中の､最新の Django ではステーブルとは限りません｡トランクバージョンで開発を行う場合､ <a class=\"reference external\" href=\"http://djangoci.com\">Django の継続インテグレーションビルド</a> をチェックしてください｡これで､テストの失敗があなたのマシンだけのものか､ Django 公式のビルドによるものかが分かります｡各ビルドについてのリンクをクリックすれば､ &quot;Configuration Matrix&quot; という､ 各 Python のバージョン､ DB バックエンドに対応したテストの失敗を閲覧できます｡</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">注釈</p>\n<p>このチュートリアルや､各チケットで作業する際は､ SQLite のテストで十分です｡しかし可能 (か必要な場合は) <a class=\"reference internal\" href=\"/ja/1.9/internals/contributing/writing-code/unit-tests/#running-unit-tests-settings\"><span class=\"std std-ref\">他のデータベースでテストを実行する</span></a> を参照してください｡</p>\n</aside>\n</section>\n<section id=\"writing-some-tests-for-your-ticket\">\n<h2>チケットにテストを書く<a class=\"heading-anchor\" href=\"#writing-some-tests-for-your-ticket\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>大抵の場合､ Django にアクセプトされるパッチはテストを含んでいます｡リグレッションテストを書くことで､ Django にバグを再混入していないと後に保証できます｡レグレッションテストは､バグが存在しているときに落ちるように書き､バグが修正された後にパスするように書かれるべきです｡新機能を含むパッチでは､その新機能が正しく動作すると保証するためにテストが必要です｡その際も同じように､新機能が無い際には落ち､実装されてから通るテストを書くべきです｡</p>\n<p>これをするには､コードに変更を加える前に先にテストを書くのが良いでしょう｡この開発手法は <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/Test-driven_development\">テスト駆動開発</a> と呼ばれ､プロジェクト全体にも単一のパッチにも適応可能です｡テストを書いた後には､テストを走らせて確かに落ちることを確認します (バグ修正や昨日の追加はまだしてないので落ちます)｡ 新しいテストが落ちない場合は落ちるよう修正しましょう｡ともかく､バグが存在していようとも通るテストは将来バグが再発するのを防ぐのに､何の役にもたちません｡</p>\n<p>ハンズオンでの例題</p>\n<section id=\"writing-some-tests-for-ticket-24788\">\n<h3>チケット #24788 にテストを書いてみましょう<a class=\"heading-anchor\" href=\"#writing-some-tests-for-ticket-24788\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>チケット <a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/24788\">#24788</a> は、Formクラスにおいてクラスレベルの属性 <code class=\"docutils literal notranslate\">prefix</code> を指定可能にするという小さな機能追加を、このように提案しています:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>[…] forms which ship with apps could effectively namespace themselves such\nthat N overlapping form fields could be POSTed at once and resolved to the\ncorrect form.\n</code></pre></div>\n<p>このチケットを解決するには､ <code class=\"docutils literal notranslate\">prefix</code> 属性を <code class=\"docutils literal notranslate\">BaseForm</code> に追加します｡このクラスのインスタンスを作成する時、 <code class=\"docutils literal notranslate\">__init__()</code> メソッドに <code class=\"docutils literal notranslate\">prefix</code> を渡すと、作成されたインスタンスに <code class=\"docutils literal notranslate\">prefix</code> がセットされます。 しかし <code class=\"docutils literal notranslate\">prefix</code> を渡さない(または <code class=\"docutils literal notranslate\">None</code> を与える)場合、クラスレベルのprefixが使用されます。変更を加える前に､変更が正しく動作し､これからも動作し続けることを確認するためにテストをいくつか追加します｡</p>\n<p>Django の <code class=\"docutils literal notranslate\">tests/forms_tests/tests/</code> フォルダに移動して <code class=\"docutils literal notranslate\">tests_forms.py</code> ファイルを開きます。以下のコードを <a href=\"#id1\"><span class=\"problematic\" id=\"id2\">``</span></a>test_forms_with_null_boolean `` 関数の直前の 1674 行目に追加します:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"k\">def</span> <span class=\"nf\">test_class_prefix</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n    <span class=\"c1\"># Prefix can be also specified at the class level.</span>\n    <span class=\"k\">class</span> <span class=\"nc\">Person</span><span class=\"p\">(</span>Form<span class=\"p\">):</span>\n        first_name <span class=\"o\">=</span> CharField<span class=\"p\">()</span>\n        prefix <span class=\"o\">=</span> <span class=\"s1\">&#39;foo&#39;</span>\n\n    p <span class=\"o\">=</span> Person<span class=\"p\">()</span>\n    <span class=\"bp\">self</span><span class=\"o\">.</span>assertEqual<span class=\"p\">(</span>p<span class=\"o\">.</span>prefix<span class=\"p\">,</span> <span class=\"s1\">&#39;foo&#39;</span><span class=\"p\">)</span>\n\n    p <span class=\"o\">=</span> Person<span class=\"p\">(</span>prefix<span class=\"o\">=</span><span class=\"s1\">&#39;bar&#39;</span><span class=\"p\">)</span>\n    <span class=\"bp\">self</span><span class=\"o\">.</span>assertEqual<span class=\"p\">(</span>p<span class=\"o\">.</span>prefix<span class=\"p\">,</span> <span class=\"s1\">&#39;bar&#39;</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>この新しいテストは、 クラスレベルの <code class=\"docutils literal notranslate\">prefix</code> が期待通りに設定されていることと、インスタンスの生成時にまだ <code class=\"docutils literal notranslate\">prefix</code> パラメータが渡されていることを確認します。</p>\n<aside class=\"admonition-but-this-testing-thing-looks-kinda-hard admonition\" role=\"note\">\n<p class=\"admonition-title\">でもテストをするのはすこし難しそうです……</p>\n<p>テストを書いたとこがない場合は､最初は難しく見えるかもしれません｡ですが実は､テスティングはプログラミングにおいて <em>とても</em> 重要なことです｡ここではテストについて詳細に紹介します｡</p>\n<ul class=\"simple\">\n<li><p>Django のための良いテストの書き方は <a class=\"reference internal\" href=\"/ja/1.9/topics/testing/overview/\"><span class=\"doc\">Writing and running tests</span></a> のドキュメントに記載されています。</p></li>\n<li><p>Dive Into Python (Python初心者のための､オンラインの無料の本) では素晴らしい <a class=\"reference external\" href=\"http://www.diveintopython.net/unit_testing/index.html\">初めてのユニットテスト</a> という章があります｡</p></li>\n<li><p>After reading those, if you want something a little meatier to sink\nyour teeth into, there's always the Python <a class=\"reference external\" href=\"https://docs.python.org/3/library/unittest.html#module-unittest\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">unittest</code></a> documentation.</p></li>\n</ul>\n</aside>\n</section>\n<section id=\"running-your-new-test\">\n<h3>新しいテストを走らせる<a class=\"heading-anchor\" href=\"#running-your-new-test\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">BaseForm `` にはまだ変更を加えていませんので､テストは落ちます｡ ``forms_tests `` フォルダの全テストを走らせて､実際に何が起こるか観てみましょう｡コマンドラインで ``tests/</code> ディレクトリに <code class=\"docutils literal notranslate\">cd</code> して､以下を実行してください:</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>./runtests.py forms_tests\n</code></pre></div>\n<p>テストが正しく実行されれば､追加したテストメソッドに対応する1つのテストが失敗するでしょう｡テストがすべて通れば､上記した新しいテストを正しいフォルダ､クラスに追加したことを確認してください｡</p>\n</section>\n</section>\n<section id=\"writing-the-code-for-your-ticket\">\n<h2>チケットにコードを書く<a class=\"heading-anchor\" href=\"#writing-the-code-for-your-ticket\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>次は :ticket:<a href=\"#id1\"><span class=\"problematic\" id=\"id2\">`</span></a>24788 ` で説明されている機能を Django に追加します｡</p>\n<section id=\"writing-the-code-for-ticket-24788\">\n<h3>チケット #24788 のコードを書いてみましょう<a class=\"heading-anchor\" href=\"#writing-the-code-for-ticket-24788\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">django/django/contrib/forms</code> フォルダーに行って､ <code class=\"docutils literal notranslate\">forms.py</code> ファイルを開いてください｡\n72行目にある <code class=\"docutils literal notranslate\">BaseForm</code> クラスを見つけて､以下の <code class=\"docutils literal notranslate\">prefix</code> クラス属性をすでにある <code class=\"docutils literal notranslate\">field_order</code> 属性の下に追加してください:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"k\">class</span> <span class=\"nc\">BaseForm</span><span class=\"p\">(</span><span class=\"nb\">object</span><span class=\"p\">):</span>\n    <span class=\"c1\"># This is the main implementation of all the Form logic. Note that this</span>\n    <span class=\"c1\"># class is different than Form. See the comments by the Form class for</span>\n    <span class=\"c1\"># more information. Any improvements to the form API should be made to</span>\n    <span class=\"c1\"># *this* class, not to the Form class.</span>\n    field_order <span class=\"o\">=</span> <span class=\"kc\">None</span>\n    prefix <span class=\"o\">=</span> <span class=\"kc\">None</span>\n</code></pre></div>\n</section>\n<section id=\"verifying-your-test-now-passes\">\n<h3>テストが通ることを確認する<a class=\"heading-anchor\" href=\"#verifying-your-test-now-passes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django への変更が完了したあと､コードが正しく動作すると確認するため､先ほど書いたテストを実行してください｡Djangoの <code class=\"docutils literal notranslate\">form_tests</code> フォルダーに <code class=\"docutils literal notranslate\">cd</code> で移動して､以下を実行してください:</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>./runtests.py forms_tests\n</code></pre></div>\n<p>あぁ､テストを書いていて良かったですね｡以下のように1つテストが落ちています:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"ne\">AssertionError</span><span class=\"p\">:</span> <span class=\"kc\">None</span> <span class=\"o\">!=</span> <span class=\"s1\">&#39;foo&#39;</span>\n</code></pre></div>\n<p><code class=\"docutils literal notranslate\">__init__``メソッドの中に条件文を追加するのを忘れていました。``django/forms/forms.py</code> の87行目の``self.prefix = prefix``を参照して変更します。条件文を追加しましょう:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"k\">if</span> prefix <span class=\"ow\">is</span> <span class=\"ow\">not</span> <span class=\"kc\">None</span><span class=\"p\">:</span>\n    <span class=\"bp\">self</span><span class=\"o\">.</span>prefix <span class=\"o\">=</span> prefix\n</code></pre></div>\n<p>再実行すればテストがすべてパスするはずです｡もしそうでない場合､ <code class=\"docutils literal notranslate\">BaseForm</code> クラスと新しいテストが正しくコピーされているされていると確認してください｡</p>\n</section>\n</section>\n<section id=\"running-django-s-test-suite-for-the-second-time\">\n<h2>Django の テストスイートをもう一度走らせる<a class=\"heading-anchor\" href=\"#running-django-s-test-suite-for-the-second-time\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>パッチとテストが正しく動作していることを確認できたら､ Django のテストをすべて走らせて､変更が Django の別の場所にバグを仕込んでいないか確認しましょう｡すべてのテストが通るという事は､追加したコードがバグフリーだと保証します｡大量のバグや手戻りを発見できます｡そうでないとバグを見逃してしまうでしょう｡</p>\n<p>Django の全てのテストスイートを走らせるには <code class=\"docutils literal notranslate\">cd</code> で Django の <code class=\"docutils literal notranslate\">tests/</code> ディレクトリ移動して実行してください:</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>./runtests.py\n</code></pre></div>\n<p>どのテストも失敗していない間は、作業を続けることができます。</p>\n</section>\n<section id=\"writing-documentation\">\n<h2>ドキュメントを書く<a class=\"heading-anchor\" href=\"#writing-documentation\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>この機能は新しいので､ドキュメントに書かれるべきです｡  <code class=\"docutils literal notranslate\">django/docs/ref/forms/api.txt</code> の 1068行目 (ファイルの最後) に追記してください:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>The prefix can also be specified on the form class::\n\n    &gt;&gt;&gt; class PersonForm(forms.Form):\n    ...     ...\n    ...     prefix = &#39;person&#39;\n\n.. versionadded:: 1.9\n\n    The ability to specify ``prefix`` on the form class was added.\n</code></pre></div>\n<p>この新機能は将来のリリースに含まれるとともに、Django 1.9のリリースノート、ファイル <code class=\"docutils literal notranslate\">docs/releases/1.9.txt</code> 164行目以降の&quot;Forms&quot;のセクションに追加されています。</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>* A form prefix can be specified inside a form class, not only when\n  instantiating a form. See :ref:`form-prefix` for details.\n</code></pre></div>\n<p>ドキュメントの書き方についてもっと知りたい場合は <a class=\"reference internal\" href=\"/ja/1.9/internals/contributing/writing-documentation/\"><span class=\"doc\">Writing documentation</span></a> を参照してください｡ここでは､ <a href=\"#id1\"><span class=\"problematic\" id=\"id2\">``</span></a>versionadded` の書き方についてや､ ドキュメントのコピーをローカルでビルドしてみて､ HTML をプレビューする方法などが書かれています｡</p>\n</section>\n<section id=\"generating-a-patch-for-your-changes\">\n<h2>変更のパッチを生成する<a class=\"heading-anchor\" href=\"#generating-a-patch-for-your-changes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Trac にアップロードされたり､他のDjangoに適応されるパッチを作りましょう｡パッチの内容を見るために､以下のコマンドを実行してください:</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>git diff\n</code></pre></div>\n<p>チュートリアルの初めでチェックアウトした最初のリビジョンと､(修正した) 現在の Django のコピーとの違いを表示します｡</p>\n<p>パッチを見終わったら､ <code class=\"docutils literal notranslate\">q</code> キーをタイプしたコマンドラインに戻りましょう｡パッチの内容が良さそうなら､以下のコマンドを実行して､現在のワーキングディレクトリにパッチを保存してください:</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>git diff &gt; <span class=\"m\">24788</span>.diff\n</code></pre></div>\n<p>Django のルートディレクトリに <code class=\"docutils literal notranslate\">24788.diff</code> というファイルが作られるでしょう｡このパッチは変更のすべてを含んでおり､このようになります:</p>\n<div class=\"code-block\" data-language=\"diff\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Diff</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Diff code\"><code><span class=\"gh\">diff --git a/django/forms/forms.py b/django/forms/forms.py</span>\n<span class=\"gh\">index 509709f..d1370de 100644</span>\n<span class=\"gd\">--- a/django/forms/forms.py</span>\n<span class=\"gi\">+++ b/django/forms/forms.py</span>\n<span class=\"gu\">@@ -75,6 +75,7 @@ class BaseForm(object):</span>\n     # information. Any improvements to the form API should be made to *this*\n     # class, not to the Form class.\n     field_order = None\n<span class=\"gi\">+    prefix = None</span>\n\n     def __init__(self, data=None, files=None, auto_id=&#39;id_%s&#39;, prefix=None,\n                  initial=None, error_class=ErrorList, label_suffix=None,\n<span class=\"gu\">@@ -83,7 +84,8 @@ class BaseForm(object):</span>\n         self.data = data or {}\n         self.files = files or {}\n         self.auto_id = auto_id\n<span class=\"gd\">-        self.prefix = prefix</span>\n<span class=\"gi\">+        if prefix is not None:</span>\n<span class=\"gi\">+            self.prefix = prefix</span>\n         self.initial = initial or {}\n         self.error_class = error_class\n         # Translators: This is the default suffix added to form field labels\n<span class=\"gh\">diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt</span>\n<span class=\"gh\">index 3bc39cd..008170d 100644</span>\n<span class=\"gd\">--- a/docs/ref/forms/api.txt</span>\n<span class=\"gi\">+++ b/docs/ref/forms/api.txt</span>\n<span class=\"gu\">@@ -1065,3 +1065,13 @@ You can put several Django forms inside one ``&lt;form&gt;`` tag. To give each</span>\n     &gt;&gt;&gt; print(father.as_ul())\n     &lt;li&gt;&lt;label for=&quot;id_father-first_name&quot;&gt;First name:&lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;father-first_name&quot; id=&quot;id_father-first_name&quot; /&gt;&lt;/li&gt;\n     &lt;li&gt;&lt;label for=&quot;id_father-last_name&quot;&gt;Last name:&lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;father-last_name&quot; id=&quot;id_father-last_name&quot; /&gt;&lt;/li&gt;\n<span class=\"gi\">+</span>\n<span class=\"gi\">+The prefix can also be specified on the form class::</span>\n<span class=\"gi\">+</span>\n<span class=\"gi\">+    &gt;&gt;&gt; class PersonForm(forms.Form):</span>\n<span class=\"gi\">+    ...     ...</span>\n<span class=\"gi\">+    ...     prefix = &#39;person&#39;</span>\n<span class=\"gi\">+</span>\n<span class=\"gi\">+.. versionadded:: 1.9</span>\n<span class=\"gi\">+</span>\n<span class=\"gi\">+    The ability to specify ``prefix`` on the form class was added.</span>\n<span class=\"gh\">diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt</span>\n<span class=\"gh\">index 5b58f79..f9bb9de 100644</span>\n<span class=\"gd\">--- a/docs/releases/1.9.txt</span>\n<span class=\"gi\">+++ b/docs/releases/1.9.txt</span>\n<span class=\"gu\">@@ -161,6 +161,9 @@ Forms</span>\n   :attr:`~django.forms.Form.field_order` attribute, the ``field_order``\n   constructor argument , or the :meth:`~django.forms.Form.order_fields` method.\n\n<span class=\"gi\">+* A form prefix can be specified inside a form class, not only when</span>\n<span class=\"gi\">+  instantiating a form. See :ref:`form-prefix` for details.</span>\n<span class=\"gi\">+</span>\n Generic Views\n ^^^^^^^^^^^^^\n\n<span class=\"gh\">diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py</span>\n<span class=\"gh\">index 690f205..e07fae2 100644</span>\n<span class=\"gd\">--- a/tests/forms_tests/tests/test_forms.py</span>\n<span class=\"gi\">+++ b/tests/forms_tests/tests/test_forms.py</span>\n<span class=\"gu\">@@ -1671,6 +1671,18 @@ class FormsTestCase(SimpleTestCase):</span>\n         self.assertEqual(p.cleaned_data[&#39;last_name&#39;], &#39;Lennon&#39;)\n         self.assertEqual(p.cleaned_data[&#39;birthday&#39;], datetime.date(1940, 10, 9))\n\n<span class=\"gi\">+    def test_class_prefix(self):</span>\n<span class=\"gi\">+        # Prefix can be also specified at the class level.</span>\n<span class=\"gi\">+        class Person(Form):</span>\n<span class=\"gi\">+            first_name = CharField()</span>\n<span class=\"gi\">+            prefix = &#39;foo&#39;</span>\n<span class=\"gi\">+</span>\n<span class=\"gi\">+        p = Person()</span>\n<span class=\"gi\">+        self.assertEqual(p.prefix, &#39;foo&#39;)</span>\n<span class=\"gi\">+</span>\n<span class=\"gi\">+        p = Person(prefix=&#39;bar&#39;)</span>\n<span class=\"gi\">+        self.assertEqual(p.prefix, &#39;bar&#39;)</span>\n<span class=\"gi\">+</span>\n     def test_forms_with_null_boolean(self):\n         # NullBooleanField is a bit of a special case because its presentation (widget)\n         # is different than its data. This is handled transparently, though.\n</code></pre></div>\n</section>\n<section id=\"so-what-do-i-do-next\">\n<h2>次はどうしましょうか?<a class=\"heading-anchor\" href=\"#so-what-do-i-do-next\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>おめでとうございます! Django への最初のパッチができました! パッチの書き方を習得したので､ Django のコードベースを改善するためにスキルを活かしましょう｡パッチを生成して､Tracのチケットに貼り付けるのは便利ですが､ git を使っている場合は､ <a class=\"reference external\" href=\"/ja/1.9/internals/contributing/writing-code/working-with-git/\">git ワークフロー</a> の利用がオススメです｡</p>\n<p>変更をローカルでコミットしなかった場合は､ git のブランチを始めに戻すために以下を実行してください:</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>git reset --hard HEAD\n<span class=\"gp\">$ </span>git checkout master\n</code></pre></div>\n<section id=\"more-information-for-new-contributors\">\n<h3>新しい貢献者のための情報<a class=\"heading-anchor\" href=\"#more-information-for-new-contributors\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django へのパッチを書き始める前に､貢献するために見ておいたほうがいい情報があります:</p>\n<ul class=\"simple\">\n<li><p>Django のドキュメントの <a class=\"reference external\" href=\"/ja/1.9/internals/contributing/writing-code/submitting-patches/\">チケットをクレームして､パッチを送信する</a> を読んでください｡ Trac でのエチケットやチケットをクレームする方法やパッチに適切なコーディングスタイルなど､重要なことを網羅できます｡</p></li>\n<li><p>Django への初めての貢献者は <a class=\"reference internal\" href=\"/ja/1.9/internals/contributing/new-contributors/\"><span class=\"doc\">初めての貢献者へのドキュメント</span></a> を読んでください｡Django に初めて協力する人たちへの良いアドバイスがあります｡</p></li>\n<li><p>貢献について､より多くの情報を知りたいなら､ <a class=\"reference internal\" href=\"/ja/1.9/internals/contributing/\"><span class=\"doc\">貢献についての Django のドキュメント</span></a> を参照してください｡そこにはたくさん有用な情報がありまし､質問があれば､このドキュメントが1番役に立ちます｡</p></li>\n</ul>\n</section>\n<section id=\"finding-your-first-real-ticket\">\n<h3>実際にチケットを探してみましょう<a class=\"heading-anchor\" href=\"#finding-your-first-real-ticket\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>ドキュメントをたくさん読んだ後は､実際のパッチを書けるのでチケットを探してみましょう｡ &quot;easy picking&quot; タグが付いたチケットを見つけてください｡このチケットは大抵はより簡単なものなので､初めての貢献者には適切でしょう｡ Django への貢献に慣れてきたあとは､難しく､複雑なチケットを書き始めれるでしょう｡</p>\n<p>今すぐ始めたいなら (責める人はいません！)、　<a class=\"reference external\" href=\"https://code.djangoproject.com/query?status=new&amp;status=reopened&amp;has_patch=0&amp;easy=1&amp;col=id&amp;col=summary&amp;col=status&amp;col=owner&amp;col=type&amp;col=milestone&amp;order=priority\">パッチが必要な簡単なチケット</a> か <a class=\"reference external\" href=\"https://code.djangoproject.com/query?status=new&amp;status=reopened&amp;needs_better_patch=1&amp;easy=1&amp;col=id&amp;col=summary&amp;col=status&amp;col=owner&amp;col=type&amp;col=milestone&amp;order=priority\">パッチに改善が必要な簡単なチケット</a> を見つけましょう。テストを書きなれているなら <a class=\"reference external\" href=\"https://code.djangoproject.com/query?status=new&amp;status=reopened&amp;needs_tests=1&amp;easy=1&amp;col=id&amp;col=summary&amp;col=status&amp;col=owner&amp;col=type&amp;col=milestone&amp;order=priority\">テストが必要な簡単なチケット</a> でもよいでしょう。ただ、チケットのクレームに関するガイドラインに従ってください。 Django ドキュメントの <a class=\"reference internal\" href=\"/ja/1.9/internals/contributing/writing-code/submitting-patches/\"><span class=\"doc\">チケットをクレームしてパッチを送る</span></a> で記述されています。</p>\n</section>\n<section id=\"what-s-next\">\n<h3>次は何をしましょうか？<a class=\"heading-anchor\" href=\"#what-s-next\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>チケットにパッチが追加されたあとは、別の人間の目でレビューされる必要があります。パッチをアップロードしたりプルリクエストを送信したあとは、チケットのメタデータから &quot;has patch&quot; フラグを設定してください。 &quot;doesn't need tests&quot; や、その他のメタデータはレビューのためにあります。貢献する際にはいつもスクラッチからパッチを書くというわけではありません。既存のパッチをレビューすることをまた素晴らしく役に立つ貢献です。詳細は <a class=\"reference internal\" href=\"/ja/1.9/internals/contributing/triaging-tickets/\"><span class=\"doc\">Triaging tickets</span></a> を参照してください。</p>\n</section>\n</section>","rootId":"writing-your-first-patch-for-django","toc":[{"title":"はじめに","anchor":"introduction","children":[{"title":"このチュートリアルは誰を対象としていますか?","anchor":"who-s-this-tutorial-for","children":[]},{"title":"このチュートリアルの範囲はなんですか?","anchor":"what-does-this-tutorial-cover","children":[]}]},{"title":"ソースコードの管理","anchor":"code-of-conduct","children":[]},{"title":"Git のインストール","anchor":"installing-git","children":[]},{"title":"Django 開発版の複製を取得","anchor":"getting-a-copy-of-django-s-development-version","children":[]},{"title":"旧リビジョンの Django に戻す","anchor":"rolling-back-to-a-previous-revision-of-django","children":[]},{"title":"最初に Django のテストスイートを実行する","anchor":"running-django-s-test-suite-for-the-first-time","children":[]},{"title":"チケットにテストを書く","anchor":"writing-some-tests-for-your-ticket","children":[{"title":"チケット #24788 にテストを書いてみましょう","anchor":"writing-some-tests-for-ticket-24788","children":[]},{"title":"新しいテストを走らせる","anchor":"running-your-new-test","children":[]}]},{"title":"チケットにコードを書く","anchor":"writing-the-code-for-your-ticket","children":[{"title":"チケット #24788 のコードを書いてみましょう","anchor":"writing-the-code-for-ticket-24788","children":[]},{"title":"テストが通ることを確認する","anchor":"verifying-your-test-now-passes","children":[]}]},{"title":"Django の テストスイートをもう一度走らせる","anchor":"running-django-s-test-suite-for-the-second-time","children":[]},{"title":"ドキュメントを書く","anchor":"writing-documentation","children":[]},{"title":"変更のパッチを生成する","anchor":"generating-a-patch-for-your-changes","children":[]},{"title":"次はどうしましょうか?","anchor":"so-what-do-i-do-next","children":[{"title":"新しい貢献者のための情報","anchor":"more-information-for-new-contributors","children":[]},{"title":"実際にチケットを探してみましょう","anchor":"finding-your-first-real-ticket","children":[]},{"title":"次は何をしましょうか？","anchor":"what-s-next","children":[]}]}],"breadcrumbs":[{"docname":"intro/index","title":"さぁ始めましょう。","url":"/ja/1.9/intro/"}],"prev":{"docname":"intro/whatsnext","title":"次のステップへ","url":"/ja/1.9/intro/whatsnext/"},"next":{"docname":"topics/index","title":"Using Django","url":"/ja/1.9/topics/"},"formats":{"html":"/ja/1.9/intro/contributing/","markdown":"/ja/1.9/intro/contributing.md","json":"/ja/1.9/intro/contributing.json"},"source":"https://github.com/django/django/blob/stable/1.9.x/docs/intro/contributing.txt","official":"https://docs.djangoproject.com/ja/1.9/intro/contributing/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9"],"inLocales":["en","fr","ja","id","pt-br","es"]}