contributing.txt 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. ===================================
  2. Writing your first patch for Django
  3. ===================================
  4. Introduction
  5. ============
  6. Interested in giving back to the community a little? Maybe you've found a bug
  7. in Django that you'd like to see fixed, or maybe there's a small feature you
  8. want added.
  9. Contributing back to Django itself is the best way to see your own concerns
  10. addressed. This may seem daunting at first, but it's really pretty simple.
  11. We'll walk you through the entire process, so you can learn by example.
  12. Who's this tutorial for?
  13. ------------------------
  14. .. seealso::
  15. If you are looking for a reference on how to submit patches, see the
  16. :doc:`/internals/contributing/writing-code/submitting-patches`
  17. documentation.
  18. For this tutorial, we expect that you have at least a basic understanding of
  19. how Django works. This means you should be comfortable going through the
  20. existing tutorials on :doc:`writing your first Django app</intro/tutorial01>`.
  21. In addition, you should have a good understanding of Python itself. But if you
  22. don't, `Dive Into Python`__ is a fantastic (and free) online book for
  23. beginning Python programmers.
  24. Those of you who are unfamiliar with version control systems and Trac will find
  25. that this tutorial and its links include just enough information to get started.
  26. However, you'll probably want to read some more about these different tools if
  27. you plan on contributing to Django regularly.
  28. For the most part though, this tutorial tries to explain as much as possible,
  29. so that it can be of use to the widest audience.
  30. .. admonition:: Where to get help:
  31. If you're having trouble going through this tutorial, please post a message
  32. to |django-developers| or drop by `#django-dev on irc.freenode.net`__ to
  33. chat with other Django users who might be able to help.
  34. __ http://www.diveintopython3.net/
  35. __ irc://irc.freenode.net/django-dev
  36. What does this tutorial cover?
  37. ------------------------------
  38. We'll be walking you through contributing a patch to Django for the first time.
  39. By the end of this tutorial, you should have a basic understanding of both the
  40. tools and the processes involved. Specifically, we'll be covering the following:
  41. * Installing Git.
  42. * How to download a development copy of Django.
  43. * Running Django's test suite.
  44. * Writing a test for your patch.
  45. * Writing the code for your patch.
  46. * Testing your patch.
  47. * Generating a patch file for your changes.
  48. * Where to look for more information.
  49. Once you're done with the tutorial, you can look through the rest of
  50. :doc:`Django's documentation on contributing</internals/contributing/index>`.
  51. It contains lots of great information and is a must read for anyone who'd like
  52. to become a regular contributor to Django. If you've got questions, it's
  53. probably got the answers.
  54. .. admonition:: Python 3 required!
  55. This tutorial assumes you are using Python 3. Get the latest version at
  56. `Python's download page <https://www.python.org/download/>`_ or with your
  57. operating system's package manager.
  58. .. admonition:: For Windows users
  59. When installing Python on Windows, make sure you check the option "Add
  60. python.exe to Path", so that it is always available on the command line.
  61. Code of Conduct
  62. ===============
  63. As a contributor, you can help us keep the Django community open and inclusive.
  64. Please read and follow our `Code of Conduct <https://www.djangoproject.com/conduct/>`_.
  65. Installing Git
  66. ==============
  67. For this tutorial, you'll need Git installed to download the current
  68. development version of Django and to generate patch files for the changes you
  69. make.
  70. To check whether or not you have Git installed, enter ``git`` into the command
  71. line. If you get messages saying that this command could not be found, you'll
  72. have to download and install it, see `Git's download page`__.
  73. .. admonition:: For Windows users
  74. When installing Git on Windows, it is recommended that you pick the
  75. "Git Bash" option so that Git runs in its own shell. This tutorial assumes
  76. that's how you have installed it.
  77. If you're not that familiar with Git, you can always find out more about its
  78. commands (once it's installed) by typing ``git help`` into the command line.
  79. __ http://git-scm.com/download
  80. Getting a copy of Django's development version
  81. ==============================================
  82. The first step to contributing to Django is to get a copy of the source code.
  83. From the command line, use the ``cd`` command to navigate to the directory
  84. where you'll want your local copy of Django to live.
  85. Download the Django source code repository using the following command:
  86. .. code-block:: console
  87. $ git clone https://github.com/django/django.git
  88. Now that you have a local copy of Django, you can install it just like you would
  89. install any package using ``pip``. The most convenient way to do so is by using
  90. a *virtual environment* (or virtualenv) which is a feature built into Python
  91. that allows you to keep a separate directory of installed packages for each of
  92. your projects so that they don't interfere with each other.
  93. It's a good idea to keep all your virtualenvs in one place, for example in
  94. ``.virtualenvs/`` in your home directory. Create it if it doesn't exist yet:
  95. .. code-block:: console
  96. $ mkdir ~/.virtualenvs
  97. Now create a new virtualenv by running:
  98. .. code-block:: console
  99. $ python3 -m venv ~/.virtualenvs/djangodev
  100. The path is where the new environment will be saved on your computer.
  101. .. admonition:: For Windows users
  102. Using the built-in ``venv`` module will not work if you are also using the
  103. Git Bash shell on Windows, since activation scripts are only created for the
  104. system shell (``.bat``) and PowerShell (``.ps1``). Use the ``virtualenv``
  105. package instead:
  106. .. code-block:: none
  107. $ pip install virtualenv
  108. $ virtualenv ~/.virtualenvs/djangodev
  109. .. admonition:: For Ubuntu users
  110. On some versions of Ubuntu the above command might fail. Use the
  111. ``virtualenv`` package instead, first making sure you have ``pip3``:
  112. .. code-block:: console
  113. $ sudo apt-get install python3-pip
  114. $ # Prefix the next command with sudo if it gives a permission denied error
  115. $ pip3 install virtualenv
  116. $ virtualenv --python=`which python3` ~/.virtualenvs/djangodev
  117. The final step in setting up your virtualenv is to activate it:
  118. .. code-block:: console
  119. $ source ~/.virtualenvs/djangodev/bin/activate
  120. If the ``source`` command is not available, you can try using a dot instead:
  121. .. code-block:: console
  122. $ . ~/.virtualenvs/djangodev/bin/activate
  123. .. admonition:: For Windows users
  124. To activate your virtualenv on Windows, run:
  125. .. code-block:: none
  126. $ source ~/virtualenvs/djangodev/Scripts/activate
  127. You have to activate the virtualenv whenever you open a new terminal window.
  128. virtualenvwrapper__ is a useful tool for making this more convenient.
  129. __ https://virtualenvwrapper.readthedocs.org/en/latest/
  130. Anything you install through ``pip`` from now on will be installed in your new
  131. virtualenv, isolated from other environments and system-wide packages. Also, the
  132. name of the currently activated virtualenv is displayed on the command line to
  133. help you keep track of which one you are using. Go ahead and install the
  134. previously cloned copy of Django:
  135. .. code-block:: console
  136. $ pip install -e /path/to/your/local/clone/django/
  137. The installed version of Django is now pointing at your local copy. You will
  138. immediately see any changes you make to it, which is of great help when writing
  139. your first patch.
  140. Rolling back to a previous revision of Django
  141. =============================================
  142. For this tutorial, we'll be using ticket :ticket:`24788` as a case study, so
  143. we'll rewind Django's version history in git to before that ticket's patch was
  144. applied. This will allow us to go through all of the steps involved in writing
  145. that patch from scratch, including running Django's test suite.
  146. **Keep in mind that while we'll be using an older revision of Django's trunk
  147. for the purposes of the tutorial below, you should always use the current
  148. development revision of Django when working on your own patch for a ticket!**
  149. .. note::
  150. The patch for this ticket was written by Paweł Marczewski, and it was
  151. applied to Django as `commit 4df7e8483b2679fc1cba3410f08960bac6f51115`__.
  152. Consequently, we'll be using the revision of Django just prior to that,
  153. `commit 4ccfc4439a7add24f8db4ef3960d02ef8ae09887`__.
  154. __ https://github.com/django/django/commit/4df7e8483b2679fc1cba3410f08960bac6f51115
  155. __ https://github.com/django/django/commit/4ccfc4439a7add24f8db4ef3960d02ef8ae09887
  156. Navigate into Django's root directory (that's the one that contains ``django``,
  157. ``docs``, ``tests``, ``AUTHORS``, etc.). You can then check out the older
  158. revision of Django that we'll be using in the tutorial below:
  159. .. code-block:: console
  160. $ git checkout 4ccfc4439a7add24f8db4ef3960d02ef8ae09887
  161. Running Django's test suite for the first time
  162. ==============================================
  163. When contributing to Django it's very important that your code changes don't
  164. introduce bugs into other areas of Django. One way to check that Django still
  165. works after you make your changes is by running Django's test suite. If all
  166. the tests still pass, then you can be reasonably sure that your changes
  167. haven't completely broken Django. If you've never run Django's test suite
  168. before, it's a good idea to run it once beforehand just to get familiar with
  169. what its output is supposed to look like.
  170. Before running the test suite, install its dependencies by first ``cd``-ing
  171. into the Django ``tests/`` directory and then running:
  172. .. code-block:: console
  173. $ pip install -r requirements/py3.txt
  174. Now we are ready to run the test suite. If you're using GNU/Linux, Mac OS X or
  175. some other flavor of Unix, run:
  176. .. code-block:: console
  177. $ ./runtests.py
  178. Now sit back and relax. Django's entire test suite has over 9,600 different
  179. tests, so it can take anywhere from 5 to 15 minutes to run, depending on the
  180. speed of your computer.
  181. While Django's test suite is running, you'll see a stream of characters
  182. representing the status of each test as it's run. ``E`` indicates that an error
  183. was raised during a test, and ``F`` indicates that a test's assertions failed.
  184. Both of these are considered to be test failures. Meanwhile, ``x`` and ``s``
  185. indicated expected failures and skipped tests, respectively. Dots indicate
  186. passing tests.
  187. Skipped tests are typically due to missing external libraries required to run
  188. the test; see :ref:`running-unit-tests-dependencies` for a list of dependencies
  189. and be sure to install any for tests related to the changes you are making (we
  190. won't need any for this tutorial).
  191. Once the tests complete, you should be greeted with a message informing you
  192. whether the test suite passed or failed. Since you haven't yet made any changes
  193. to Django's code, the entire test suite **should** pass. If you get failures or
  194. errors make sure you've followed all of the previous steps properly. See
  195. :ref:`running-unit-tests` for more information.
  196. Note that the latest Django trunk may not always be stable. When developing
  197. against trunk, you can check `Django's continuous integration builds`__ to
  198. determine if the failures are specific to your machine or if they are also
  199. present in Django's official builds. If you click to view a particular build,
  200. you can view the "Configuration Matrix" which shows failures broken down by
  201. Python version and database backend.
  202. __ http://djangoci.com
  203. .. note::
  204. For this tutorial and the ticket we're working on, testing against SQLite
  205. is sufficient, however, it's possible (and sometimes necessary) to
  206. :ref:`run the tests using a different database
  207. <running-unit-tests-settings>`.
  208. Writing some tests for your ticket
  209. ==================================
  210. In most cases, for a patch to be accepted into Django it has to include tests.
  211. For bug fix patches, this means writing a regression test to ensure that the
  212. bug is never reintroduced into Django later on. A regression test should be
  213. written in such a way that it will fail while the bug still exists and pass
  214. once the bug has been fixed. For patches containing new features, you'll need
  215. to include tests which ensure that the new features are working correctly.
  216. They too should fail when the new feature is not present, and then pass once it
  217. has been implemented.
  218. A good way to do this is to write your new tests first, before making any
  219. changes to the code. This style of development is called
  220. `test-driven development`__ and can be applied to both entire projects and
  221. single patches. After writing your tests, you then run them to make sure that
  222. they do indeed fail (since you haven't fixed that bug or added that feature
  223. yet). If your new tests don't fail, you'll need to fix them so that they do.
  224. After all, a regression test that passes regardless of whether a bug is present
  225. is not very helpful at preventing that bug from reoccurring down the road.
  226. Now for our hands-on example.
  227. __ https://en.wikipedia.org/wiki/Test-driven_development
  228. Writing some tests for ticket #24788
  229. ------------------------------------
  230. Ticket :ticket:`24788` proposes a small feature addition: the ability to
  231. specify the class level attribute ``prefix`` on Form classes, so that::
  232. […] forms which ship with apps could effectively namespace themselves such
  233. that N overlapping form fields could be POSTed at once and resolved to the
  234. correct form.
  235. In order to resolve this ticket, we'll add a ``prefix`` attribute to the
  236. ``BaseForm`` class. When creating instances of this class, passing a prefix to
  237. the ``__init__()`` method will still set that prefix on the created instance.
  238. But not passing a prefix (or passing ``None``) will use the class-level prefix.
  239. Before we make those changes though, we're going to write a couple tests to
  240. verify that our modification functions correctly and continues to function
  241. correctly in the future.
  242. Navigate to Django's ``tests/forms_tests/tests/`` folder and open the
  243. ``test_forms.py`` file. Add the following code on line 1674 right before the
  244. ``test_forms_with_null_boolean`` function::
  245. def test_class_prefix(self):
  246. # Prefix can be also specified at the class level.
  247. class Person(Form):
  248. first_name = CharField()
  249. prefix = 'foo'
  250. p = Person()
  251. self.assertEqual(p.prefix, 'foo')
  252. p = Person(prefix='bar')
  253. self.assertEqual(p.prefix, 'bar')
  254. This new test checks that setting a class level prefix works as expected, and
  255. that passing a ``prefix`` parameter when creating an instance still works too.
  256. .. admonition:: But this testing thing looks kinda hard...
  257. If you've never had to deal with tests before, they can look a little hard
  258. to write at first glance. Fortunately, testing is a *very* big subject in
  259. computer programming, so there's lots of information out there:
  260. * A good first look at writing tests for Django can be found in the
  261. documentation on :doc:`/topics/testing/overview`.
  262. * Dive Into Python (a free online book for beginning Python developers)
  263. includes a great `introduction to Unit Testing`__.
  264. * After reading those, if you want something a little meatier to sink
  265. your teeth into, there's always the `Python unittest documentation`__.
  266. __ http://www.diveintopython.net/unit_testing/index.html
  267. __ https://docs.python.org/library/unittest.html
  268. Running your new test
  269. ---------------------
  270. Remember that we haven't actually made any modifications to ``BaseForm`` yet,
  271. so our tests are going to fail. Let's run all the tests in the ``forms_tests``
  272. folder to make sure that's really what happens. From the command line, ``cd``
  273. into the Django ``tests/`` directory and run:
  274. .. code-block:: console
  275. $ ./runtests.py forms_tests
  276. If the tests ran correctly, you should see one failure corresponding to the test
  277. method we added. If all of the tests passed, then you'll want to make sure that
  278. you added the new test shown above to the appropriate folder and class.
  279. Writing the code for your ticket
  280. ================================
  281. Next we'll be adding the functionality described in ticket :ticket:`24788` to
  282. Django.
  283. Writing the code for ticket #24788
  284. ----------------------------------
  285. Navigate to the ``django/django/forms/`` folder and open the ``forms.py`` file.
  286. Find the ``BaseForm`` class on line 72 and add the ``prefix`` class attribute
  287. right after the ``field_order`` attribute::
  288. class BaseForm(object):
  289. # This is the main implementation of all the Form logic. Note that this
  290. # class is different than Form. See the comments by the Form class for
  291. # more information. Any improvements to the form API should be made to
  292. # *this* class, not to the Form class.
  293. field_order = None
  294. prefix = None
  295. Verifying your test now passes
  296. ------------------------------
  297. Once you're done modifying Django, we need to make sure that the tests we wrote
  298. earlier pass, so we can see whether the code we wrote above is working
  299. correctly. To run the tests in the ``forms_tests`` folder, ``cd`` into the
  300. Django ``tests/`` directory and run:
  301. .. code-block:: console
  302. $ ./runtests.py forms_tests
  303. Oops, good thing we wrote those tests! You should still see one failure with
  304. the following exception::
  305. AssertionError: None != 'foo'
  306. We forgot to add the conditional statement in the ``__init__`` method. Go ahead
  307. and change ``self.prefix = prefix`` that is now on line 87 of
  308. ``django/forms/forms.py``, adding a conditional statement::
  309. if prefix is not None:
  310. self.prefix = prefix
  311. Re-run the tests and everything should pass. If it doesn't, make sure you
  312. correctly modified the ``BaseForm`` class as shown above and copied the new test
  313. correctly.
  314. Running Django's test suite for the second time
  315. ===============================================
  316. Once you've verified that your patch and your test are working correctly, it's
  317. a good idea to run the entire Django test suite just to verify that your change
  318. hasn't introduced any bugs into other areas of Django. While successfully
  319. passing the entire test suite doesn't guarantee your code is bug free, it does
  320. help identify many bugs and regressions that might otherwise go unnoticed.
  321. To run the entire Django test suite, ``cd`` into the Django ``tests/``
  322. directory and run:
  323. .. code-block:: console
  324. $ ./runtests.py
  325. As long as you don't see any failures, you're good to go.
  326. Writing Documentation
  327. =====================
  328. This is a new feature, so it should be documented. Add the following section on
  329. line 1068 (at the end of the file) of ``django/docs/ref/forms/api.txt``::
  330. The prefix can also be specified on the form class::
  331. >>> class PersonForm(forms.Form):
  332. ... ...
  333. ... prefix = 'person'
  334. .. versionadded:: 1.9
  335. The ability to specify ``prefix`` on the form class was added.
  336. Since this new feature will be in an upcoming release it is also added to the
  337. release notes for Django 1.9, on line 164 under the "Forms" section in the file
  338. ``docs/releases/1.9.txt``::
  339. * A form prefix can be specified inside a form class, not only when
  340. instantiating a form. See :ref:`form-prefix` for details.
  341. For more information on writing documentation, including an explanation of what
  342. the ``versionadded`` bit is all about, see
  343. :doc:`/internals/contributing/writing-documentation`. That page also includes
  344. an explanation of how to build a copy of the documentation locally, so you can
  345. preview the HTML that will be generated.
  346. Generating a patch for your changes
  347. ===================================
  348. Now it's time to generate a patch file that can be uploaded to Trac or applied
  349. to another copy of Django. To get a look at the content of your patch, run the
  350. following command:
  351. .. code-block:: console
  352. $ git diff
  353. This will display the differences between your current copy of Django (with
  354. your changes) and the revision that you initially checked out earlier in the
  355. tutorial.
  356. Once you're done looking at the patch, hit the ``q`` key to exit back to the
  357. command line. If the patch's content looked okay, you can run the following
  358. command to save the patch file to your current working directory:
  359. .. code-block:: console
  360. $ git diff > 24788.diff
  361. You should now have a file in the root Django directory called ``24788.diff``.
  362. This patch file contains all your changes and should look this:
  363. .. code-block:: diff
  364. diff --git a/django/forms/forms.py b/django/forms/forms.py
  365. index 509709f..d1370de 100644
  366. --- a/django/forms/forms.py
  367. +++ b/django/forms/forms.py
  368. @@ -75,6 +75,7 @@ class BaseForm(object):
  369. # information. Any improvements to the form API should be made to *this*
  370. # class, not to the Form class.
  371. field_order = None
  372. + prefix = None
  373. def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
  374. initial=None, error_class=ErrorList, label_suffix=None,
  375. @@ -83,7 +84,8 @@ class BaseForm(object):
  376. self.data = data or {}
  377. self.files = files or {}
  378. self.auto_id = auto_id
  379. - self.prefix = prefix
  380. + if prefix is not None:
  381. + self.prefix = prefix
  382. self.initial = initial or {}
  383. self.error_class = error_class
  384. # Translators: This is the default suffix added to form field labels
  385. diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt
  386. index 3bc39cd..008170d 100644
  387. --- a/docs/ref/forms/api.txt
  388. +++ b/docs/ref/forms/api.txt
  389. @@ -1065,3 +1065,13 @@ You can put several Django forms inside one ``<form>`` tag. To give each
  390. >>> print(father.as_ul())
  391. <li><label for="id_father-first_name">First name:</label> <input type="text" name="father-first_name" id="id_father-first_name" /></li>
  392. <li><label for="id_father-last_name">Last name:</label> <input type="text" name="father-last_name" id="id_father-last_name" /></li>
  393. +
  394. +The prefix can also be specified on the form class::
  395. +
  396. + >>> class PersonForm(forms.Form):
  397. + ... ...
  398. + ... prefix = 'person'
  399. +
  400. +.. versionadded:: 1.9
  401. +
  402. + The ability to specify ``prefix`` on the form class was added.
  403. diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt
  404. index 5b58f79..f9bb9de 100644
  405. --- a/docs/releases/1.9.txt
  406. +++ b/docs/releases/1.9.txt
  407. @@ -161,6 +161,9 @@ Forms
  408. :attr:`~django.forms.Form.field_order` attribute, the ``field_order``
  409. constructor argument , or the :meth:`~django.forms.Form.order_fields` method.
  410. +* A form prefix can be specified inside a form class, not only when
  411. + instantiating a form. See :ref:`form-prefix` for details.
  412. +
  413. Generic Views
  414. ^^^^^^^^^^^^^
  415. diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
  416. index 690f205..e07fae2 100644
  417. --- a/tests/forms_tests/tests/test_forms.py
  418. +++ b/tests/forms_tests/tests/test_forms.py
  419. @@ -1671,6 +1671,18 @@ class FormsTestCase(SimpleTestCase):
  420. self.assertEqual(p.cleaned_data['last_name'], 'Lennon')
  421. self.assertEqual(p.cleaned_data['birthday'], datetime.date(1940, 10, 9))
  422. + def test_class_prefix(self):
  423. + # Prefix can be also specified at the class level.
  424. + class Person(Form):
  425. + first_name = CharField()
  426. + prefix = 'foo'
  427. +
  428. + p = Person()
  429. + self.assertEqual(p.prefix, 'foo')
  430. +
  431. + p = Person(prefix='bar')
  432. + self.assertEqual(p.prefix, 'bar')
  433. +
  434. def test_forms_with_null_boolean(self):
  435. # NullBooleanField is a bit of a special case because its presentation (widget)
  436. # is different than its data. This is handled transparently, though.
  437. So what do I do next?
  438. =====================
  439. Congratulations, you've generated your very first Django patch! Now that you've
  440. got that under your belt, you can put those skills to good use by helping to
  441. improve Django's codebase. Generating patches and attaching them to Trac
  442. tickets is useful, however, since we are using git - adopting a more :doc:`git
  443. oriented workflow </internals/contributing/writing-code/working-with-git>` is
  444. recommended.
  445. Since we never committed our changes locally, perform the following to get your
  446. git branch back to a good starting point:
  447. .. code-block:: console
  448. $ git reset --hard HEAD
  449. $ git checkout master
  450. More information for new contributors
  451. -------------------------------------
  452. Before you get too into writing patches for Django, there's a little more
  453. information on contributing that you should probably take a look at:
  454. * You should make sure to read Django's documentation on
  455. :doc:`claiming tickets and submitting patches
  456. </internals/contributing/writing-code/submitting-patches>`.
  457. It covers Trac etiquette, how to claim tickets for yourself, expected
  458. coding style for patches, and many other important details.
  459. * First time contributors should also read Django's :doc:`documentation
  460. for first time contributors</internals/contributing/new-contributors/>`.
  461. It has lots of good advice for those of us who are new to helping out
  462. with Django.
  463. * After those, if you're still hungry for more information about
  464. contributing, you can always browse through the rest of
  465. :doc:`Django's documentation on contributing</internals/contributing/index>`.
  466. It contains a ton of useful information and should be your first source
  467. for answering any questions you might have.
  468. Finding your first real ticket
  469. ------------------------------
  470. Once you've looked through some of that information, you'll be ready to go out
  471. and find a ticket of your own to write a patch for. Pay special attention to
  472. tickets with the "easy pickings" criterion. These tickets are often much
  473. simpler in nature and are great for first time contributors. Once you're
  474. familiar with contributing to Django, you can move on to writing patches for
  475. more difficult and complicated tickets.
  476. If you just want to get started already (and nobody would blame you!), try
  477. taking a look at the list of `easy tickets that need patches`__ and the
  478. `easy tickets that have patches which need improvement`__. If you're familiar
  479. with writing tests, you can also look at the list of
  480. `easy tickets that need tests`__. Just remember to follow the guidelines about
  481. claiming tickets that were mentioned in the link to Django's documentation on
  482. :doc:`claiming tickets and submitting patches
  483. </internals/contributing/writing-code/submitting-patches>`.
  484. __ https://code.djangoproject.com/query?status=new&status=reopened&has_patch=0&easy=1&col=id&col=summary&col=status&col=owner&col=type&col=milestone&order=priority
  485. __ https://code.djangoproject.com/query?status=new&status=reopened&needs_better_patch=1&easy=1&col=id&col=summary&col=status&col=owner&col=type&col=milestone&order=priority
  486. __ https://code.djangoproject.com/query?status=new&status=reopened&needs_tests=1&easy=1&col=id&col=summary&col=status&col=owner&col=type&col=milestone&order=priority
  487. What's next?
  488. ------------
  489. After a ticket has a patch, it needs to be reviewed by a second set of eyes.
  490. After uploading a patch or submitting a pull request, be sure to update the
  491. ticket metadata by setting the flags on the ticket to say "has patch",
  492. "doesn't need tests", etc, so others can find it for review. Contributing
  493. doesn't necessarily always mean writing a patch from scratch. Reviewing
  494. existing patches is also a very helpful contribution. See
  495. :doc:`/internals/contributing/triaging-tickets` for details.