contributing.txt 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  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. For this tutorial, we expect that you have at least a basic understanding of
  15. how Django works. This means you should be comfortable going through the
  16. existing tutorials on :doc:`writing your first Django app</intro/tutorial01>`.
  17. In addition, you should have a good understanding of Python itself. But if you
  18. don't, `Dive Into Python`__ is a fantastic (and free) online book for beginning
  19. Python programmers.
  20. Those of you who are unfamiliar with version control systems and Trac will find
  21. that this tutorial and its links include just enough information to get started.
  22. However, you'll probably want to read some more about these different tools if
  23. you plan on contributing to Django regularly.
  24. For the most part though, this tutorial tries to explain as much as possible,
  25. so that it can be of use to the widest audience.
  26. .. admonition:: Where to get help:
  27. If you're having trouble going through this tutorial, please post a message
  28. to `django-developers`__ or drop by `#django-dev on irc.freenode.net`__ to
  29. chat with other Django users who might be able to help.
  30. __ http://diveintopython.net/toc/index.html
  31. __ http://groups.google.com/group/django-developers
  32. __ irc://irc.freenode.net/django-dev
  33. What does this tutorial cover?
  34. ------------------------------
  35. We'll be walking you through contributing a patch to Django for the first time.
  36. By the end of this tutorial, you should have a basic understanding of both the
  37. tools and the processes involved. Specifically, we'll be covering the following:
  38. * Installing Git.
  39. * How to download a development copy of Django.
  40. * Running Django's test suite.
  41. * Writing a test for your patch.
  42. * Writing the code for your patch.
  43. * Testing your patch.
  44. * Generating a patch file for your changes.
  45. * Where to look for more information.
  46. Once you're done with the tutorial, you can look through the rest of
  47. :doc:`Django's documentation on contributing</internals/contributing/index>`.
  48. It contains lots of great information and is a must read for anyone who'd like
  49. to become a regular contributor to Django. If you've got questions, it's
  50. probably got the answers.
  51. Installing Git
  52. ==============
  53. For this tutorial, you'll need Git installed to download the current
  54. development version of Django and to generate patch files for the changes you
  55. make.
  56. To check whether or not you have Git installed, enter ``git`` into the command
  57. line. If you get messages saying that this command could be found, you'll have
  58. to download and install it, see `Git's download page`__.
  59. If you're not that familiar with Git, you can always find out more about its
  60. commands (once it's installed) by typing ``git help`` into the command line.
  61. __ http://git-scm.com/download
  62. Getting a copy of Django's development version
  63. ==============================================
  64. The first step to contributing to Django is to get a copy of the source code.
  65. From the command line, use the ``cd`` command to navigate to the directory
  66. where you'll want your local copy of Django to live.
  67. Download the Django source code repository using the following command::
  68. git clone https://github.com/django/django.git
  69. .. note::
  70. For users who wish to use `virtualenv`__, you can use::
  71. pip install -e /path/to/your/local/clone/django/
  72. (where ``django`` is the directory of your clone that contains
  73. ``setup.py``) to link your cloned checkout into a virtual environment. This
  74. is a great option to isolate your development copy of Django from the rest
  75. of your system and avoids potential package conflicts.
  76. __ http://www.virtualenv.org
  77. Rolling back to a previous revision of Django
  78. =============================================
  79. For this tutorial, we'll be using `ticket #17549`__ as a case study, so we'll
  80. rewind Django's version history in git to before that ticket's patch was
  81. applied. This will allow us to go through all of the steps involved in writing
  82. that patch from scratch, including running Django's test suite.
  83. **Keep in mind that while we'll be using an older revision of Django's trunk
  84. for the purposes of the tutorial below, you should always use the current
  85. development revision of Django when working on your own patch for a ticket!**
  86. .. note::
  87. The patch for this ticket was written by Ulrich Petri, and it was applied
  88. to Django as `commit ac2052ebc84c45709ab5f0f25e685bf656ce79bc`__.
  89. Consequently, we'll be using the revision of Django just prior to that,
  90. `commit 39f5bc7fc3a4bb43ed8a1358b17fe0521a1a63ac`__.
  91. __ https://code.djangoproject.com/ticket/17549
  92. __ https://github.com/django/django/commit/ac2052ebc84c45709ab5f0f25e685bf656ce79bc
  93. __ https://github.com/django/django/commit/39f5bc7fc3a4bb43ed8a1358b17fe0521a1a63ac
  94. Navigate into Django's root directory (that's the one that contains ``django``,
  95. ``docs``, ``tests``, ``AUTHORS``, etc.). You can then check out the older
  96. revision of Django that we'll be using in the tutorial below::
  97. git checkout 39f5bc7fc3a4bb43ed8a1358b17fe0521a1a63ac
  98. Running Django's test suite for the first time
  99. ==============================================
  100. When contributing to Django it's very important that your code changes don't
  101. introduce bugs into other areas of Django. One way to check that Django still
  102. works after you make your changes is by running Django's test suite. If all
  103. the tests still pass, then you can be reasonably sure that your changes
  104. haven't completely broken Django. If you've never run Django's test suite
  105. before, it's a good idea to run it once beforehand just to get familiar with
  106. what its output is supposed to look like.
  107. We can run the test suite by simply ``cd``-ing into the Django ``tests/``
  108. directory and, if you're using GNU/Linux, Mac OS X or some other flavor of
  109. Unix, run::
  110. PYTHONPATH=.. python runtests.py --settings=test_sqlite
  111. If you're on Windows, the above should work provided that you are using
  112. "Git Bash" provided by the default Git install. GitHub has a `nice tutorial`__.
  113. __ https://help.github.com/articles/set-up-git#platform-windows
  114. .. note::
  115. If you're using ``virtualenv``, you can omit ``PYTHONPATH=..`` when running
  116. the tests. This instructs Python to look for Django in the parent directory
  117. of ``tests``. ``virtualenv`` puts your copy of Django on the ``PYTHONPATH``
  118. automatically.
  119. Now sit back and relax. Django's entire test suite has over 4800 different
  120. tests, so it can take anywhere from 5 to 15 minutes to run, depending on the
  121. speed of your computer.
  122. While Django's test suite is running, you'll see a stream of characters
  123. representing the status of each test as it's run. ``E`` indicates that an error
  124. was raised during a test, and ``F`` indicates that a test's assertions failed.
  125. Both of these are considered to be test failures. Meanwhile, ``x`` and ``s``
  126. indicated expected failures and skipped tests, respectively. Dots indicate
  127. passing tests.
  128. Skipped tests are typically due to missing external libraries required to run
  129. the test; see :ref:`running-unit-tests-dependencies` for a list of dependencies
  130. and be sure to install any for tests related to the changes you are making (we
  131. won't need any for this tutorial).
  132. Once the tests complete, you should be greeted with a message informing you
  133. whether the test suite passed or failed. Since you haven't yet made any changes
  134. to Django's code, the entire test suite **should** pass. If you get failures or
  135. errors make sure you've followed all of the previous steps properly. See
  136. :ref:`running-unit-tests` for more information.
  137. Note that the latest Django trunk may not always be stable. When developing
  138. against trunk, you can check `Django's continuous integration builds`__ to
  139. determine if the failures are specific to your machine or if they are also
  140. present in Django's official builds. If you click to view a particular build,
  141. you can view the "Configuration Matrix" which shows failures broken down by
  142. Python version and database backend.
  143. __ http://ci.djangoproject.com/
  144. .. note::
  145. For this tutorial and the ticket we're working on, testing against SQLite
  146. is sufficient, however, it's possible (and sometimes necessary) to
  147. :ref:`run the tests using a different database
  148. <running-unit-tests-settings>`.
  149. Writing some tests for your ticket
  150. ==================================
  151. In most cases, for a patch to be accepted into Django it has to include tests.
  152. For bug fix patches, this means writing a regression test to ensure that the
  153. bug is never reintroduced into Django later on. A regression test should be
  154. written in such a way that it will fail while the bug still exists and pass
  155. once the bug has been fixed. For patches containing new features, you'll need
  156. to include tests which ensure that the new features are working correctly.
  157. They too should fail when the new feature is not present, and then pass once it
  158. has been implemented.
  159. A good way to do this is to write your new tests first, before making any
  160. changes to the code. This style of development is called
  161. `test-driven development`__ and can be applied to both entire projects and
  162. single patches. After writing your tests, you then run them to make sure that
  163. they do indeed fail (since you haven't fixed that bug or added that feature
  164. yet). If your new tests don't fail, you'll need to fix them so that they do.
  165. After all, a regression test that passes regardless of whether a bug is present
  166. is not very helpful at preventing that bug from reoccurring down the road.
  167. Now for our hands-on example.
  168. __ http://en.wikipedia.org/wiki/Test-driven_development
  169. Writing some tests for ticket #17549
  170. ------------------------------------
  171. `Ticket #17549`__ describes the following, small feature addition:
  172. It's useful for URLField to give you a way to open the URL; otherwise you
  173. might as well use a CharField.
  174. In order to resolve this ticket, we'll add a ``render`` method to the
  175. ``AdminURLFieldWidget`` in order to display a clickable link above the input
  176. widget. Before we make those changes though, we're going to write a couple
  177. tests to verify that our modification functions correctly and continues to
  178. function correctly in the future.
  179. Navigate to Django's ``tests/regressiontests/admin_widgets/`` folder and
  180. open the ``tests.py`` file. Add the following code on line 269 right before the
  181. ``AdminFileWidgetTest`` class::
  182. class AdminURLWidgetTest(DjangoTestCase):
  183. def test_render(self):
  184. w = widgets.AdminURLFieldWidget()
  185. self.assertHTMLEqual(
  186. conditional_escape(w.render('test', '')),
  187. '<input class="vURLField" name="test" type="text" />'
  188. )
  189. self.assertHTMLEqual(
  190. conditional_escape(w.render('test', 'http://example.com')),
  191. '<p class="url">Currently:<a href="http://example.com">http://example.com</a><br />Change:<input class="vURLField" name="test" type="text" value="http://example.com" /></p>'
  192. )
  193. def test_render_idn(self):
  194. w = widgets.AdminURLFieldWidget()
  195. self.assertHTMLEqual(
  196. conditional_escape(w.render('test', 'http://example-äüö.com')),
  197. '<p class="url">Currently:<a href="http://xn--example--7za4pnc.com">http://example-äüö.com</a><br />Change:<input class="vURLField" name="test" type="text" value="http://example-äüö.com" /></p>'
  198. )
  199. def test_render_quoting(self):
  200. w = widgets.AdminURLFieldWidget()
  201. self.assertHTMLEqual(
  202. conditional_escape(w.render('test', 'http://example.com/<sometag>some text</sometag>')),
  203. '<p class="url">Currently:<a href="http://example.com/%3Csometag%3Esome%20text%3C/sometag%3E">http://example.com/&lt;sometag&gt;some text&lt;/sometag&gt;</a><br />Change:<input class="vURLField" name="test" type="text" value="http://example.com/<sometag>some text</sometag>" /></p>'
  204. )
  205. self.assertHTMLEqual(
  206. conditional_escape(w.render('test', 'http://example-äüö.com/<sometag>some text</sometag>')),
  207. '<p class="url">Currently:<a href="http://xn--example--7za4pnc.com/%3Csometag%3Esome%20text%3C/sometag%3E">http://example-äüö.com/&lt;sometag&gt;some text&lt;/sometag&gt;</a><br />Change:<input class="vURLField" name="test" type="text" value="http://example-äüö.com/<sometag>some text</sometag>" /></p>'
  208. )
  209. The new tests check to see that the ``render`` method we'll be adding works
  210. correctly in a couple different situations.
  211. .. admonition:: But this testing thing looks kinda hard...
  212. If you've never had to deal with tests before, they can look a little hard
  213. to write at first glance. Fortunately, testing is a *very* big subject in
  214. computer programming, so there's lots of information out there:
  215. * A good first look at writing tests for Django can be found in the
  216. documentation on :doc:`Testing Django applications </topics/testing/overview>`.
  217. * Dive Into Python (a free online book for beginning Python developers)
  218. includes a great `introduction to Unit Testing`__.
  219. * After reading those, if you want something a little meatier to sink
  220. your teeth into, there's always the `Python unittest documentation`__.
  221. __ https://code.djangoproject.com/ticket/17549
  222. __ http://diveintopython.net/unit_testing/index.html
  223. __ http://docs.python.org/library/unittest.html
  224. Running your new test
  225. ---------------------
  226. Remember that we haven't actually made any modifications to
  227. ``AdminURLFieldWidget`` yet, so our tests are going to fail. Let's run all the
  228. tests in the ``model_forms_regress`` folder to make sure that's really what
  229. happens. From the command line, ``cd`` into the Django ``tests/`` directory
  230. and run::
  231. PYTHONPATH=.. python runtests.py --settings=test_sqlite admin_widgets
  232. If the tests ran correctly, you should see three failures corresponding to each
  233. of the test methods we added. If all of the tests passed, then you'll want to
  234. make sure that you added the new test shown above to the appropriate folder and
  235. class.
  236. Writing the code for your ticket
  237. ================================
  238. Next we'll be adding the functionality described in `ticket #17549`__ to Django.
  239. Writing the code for ticket #17549
  240. ----------------------------------
  241. Navigate to the ``django/django/contrib/admin/`` folder and open the
  242. ``widgets.py`` file. Find the ``AdminURLFieldWidget`` class on line 302 and add
  243. the following ``render`` method after the existing ``__init__`` method::
  244. def render(self, name, value, attrs=None):
  245. html = super(AdminURLFieldWidget, self).render(name, value, attrs)
  246. if value:
  247. value = force_text(self._format_value(value))
  248. final_attrs = {'href': mark_safe(smart_urlquote(value))}
  249. html = format_html(
  250. '<p class="url">{0} <a {1}>{2}</a><br />{3} {4}</p>',
  251. _('Currently:'), flatatt(final_attrs), value,
  252. _('Change:'), html
  253. )
  254. return html
  255. Verifying your test now passes
  256. ------------------------------
  257. Once you're done modifying Django, we need to make sure that the tests we wrote
  258. earlier pass, so we can see whether the code we wrote above is working
  259. correctly. To run the tests in the ``admin_widgets`` folder, ``cd`` into the
  260. Django ``tests/`` directory and run::
  261. PYTHONPATH=.. python runtests.py --settings=test_sqlite admin_widgets
  262. Oops, good thing we wrote those tests! You should still see 3 failures with
  263. the following exception::
  264. NameError: global name 'smart_urlquote' is not defined
  265. We forgot to add the import for that method. Go ahead and add the
  266. ``smart_urlquote`` import at the end of line 13 of
  267. ``django/contrib/admin/widgets.py`` so it looks as follows::
  268. from django.utils.html import escape, format_html, format_html_join, smart_urlquote
  269. Re-run the tests and everything should pass. If it doesn't, make sure you
  270. correctly modified the ``AdminURLFieldWidget`` class as shown above and
  271. copied the new tests correctly.
  272. __ https://code.djangoproject.com/ticket/17549
  273. Running Django's test suite for the second time
  274. ===============================================
  275. Once you've verified that your patch and your test are working correctly, it's
  276. a good idea to run the entire Django test suite just to verify that your change
  277. hasn't introduced any bugs into other areas of Django. While successfully
  278. passing the entire test suite doesn't guarantee your code is bug free, it does
  279. help identify many bugs and regressions that might otherwise go unnoticed.
  280. To run the entire Django test suite, ``cd`` into the Django ``tests/``
  281. directory and run::
  282. PYTHONPATH=.. python runtests.py --settings=test_sqlite
  283. As long as you don't see any failures, you're good to go. Note that this fix
  284. also made a `small CSS change`__ to format the new widget. You can make the
  285. change if you'd like, but we'll skip it for now in the interest of brevity.
  286. __ https://github.com/django/django/commit/ac2052ebc84c45709ab5f0f25e685bf656ce79bc#diff-0
  287. Writing Documentation
  288. =====================
  289. This is a new feature, so it should be documented. Add the following on line
  290. 925 of ``django/docs/ref/models/fields.txt`` beneath the existing docs for
  291. ``URLField``::
  292. .. versionadded:: 1.5
  293. The current value of the field will be displayed as a clickable link above the
  294. input widget.
  295. For more information on writing documentation, including an explanation of what
  296. the ``versionadded`` bit is all about, see
  297. :doc:`/internals/contributing/writing-documentation`. That page also includes
  298. an explanation of how to build a copy of the documentation locally, so you can
  299. preview the HTML that will be generated.
  300. Generating a patch for your changes
  301. ===================================
  302. Now it's time to generate a patch file that can be uploaded to Trac or applied
  303. to another copy of Django. To get a look at the content of your patch, run the
  304. following command::
  305. git diff
  306. This will display the differences between your current copy of Django (with
  307. your changes) and the revision that you initially checked out earlier in the
  308. tutorial.
  309. Once you're done looking at the patch, hit the ``q`` key to exit back to the
  310. command line. If the patch's content looked okay, you can run the following
  311. command to save the patch file to your current working directory::
  312. git diff > 17549.diff
  313. You should now have a file in the root Django directory called ``17549.diff``.
  314. This patch file contains all your changes and should look this:
  315. .. code-block:: diff
  316. diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
  317. index 1e0bc2d..9e43a10 100644
  318. --- a/django/contrib/admin/widgets.py
  319. +++ b/django/contrib/admin/widgets.py
  320. @@ -10,7 +10,7 @@ from django.contrib.admin.templatetags.admin_static import static
  321. from django.core.urlresolvers import reverse
  322. from django.forms.widgets import RadioFieldRenderer
  323. from django.forms.util import flatatt
  324. -from django.utils.html import escape, format_html, format_html_join
  325. +from django.utils.html import escape, format_html, format_html_join, smart_urlquote
  326. from django.utils.text import Truncator
  327. from django.utils.translation import ugettext as _
  328. from django.utils.safestring import mark_safe
  329. @@ -306,6 +306,18 @@ class AdminURLFieldWidget(forms.TextInput):
  330. final_attrs.update(attrs)
  331. super(AdminURLFieldWidget, self).__init__(attrs=final_attrs)
  332. + def render(self, name, value, attrs=None):
  333. + html = super(AdminURLFieldWidget, self).render(name, value, attrs)
  334. + if value:
  335. + value = force_text(self._format_value(value))
  336. + final_attrs = {'href': mark_safe(smart_urlquote(value))}
  337. + html = format_html(
  338. + '<p class="url">{0} <a {1}>{2}</a><br />{3} {4}</p>',
  339. + _('Currently:'), flatatt(final_attrs), value,
  340. + _('Change:'), html
  341. + )
  342. + return html
  343. +
  344. class AdminIntegerFieldWidget(forms.TextInput):
  345. class_name = 'vIntegerField'
  346. diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
  347. index 809d56e..d44f85f 100644
  348. --- a/docs/ref/models/fields.txt
  349. +++ b/docs/ref/models/fields.txt
  350. @@ -922,6 +922,10 @@ Like all :class:`CharField` subclasses, :class:`URLField` takes the optional
  351. :attr:`~CharField.max_length`argument. If you don't specify
  352. :attr:`~CharField.max_length`, a default of 200 is used.
  353. +.. versionadded:: 1.5
  354. +
  355. +The current value of the field will be displayed as a clickable link above the
  356. +input widget.
  357. Relationship fields
  358. ===================
  359. diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py
  360. index 4b11543..94acc6d 100644
  361. --- a/tests/regressiontests/admin_widgets/tests.py
  362. +++ b/tests/regressiontests/admin_widgets/tests.py
  363. @@ -265,6 +265,35 @@ class AdminSplitDateTimeWidgetTest(DjangoTestCase):
  364. '<p class="datetime">Datum: <input value="01.12.2007" type="text" class="vDateField" name="test_0" size="10" /><br />Zeit: <input value="09:30:00" type="text" class="vTimeField" name="test_1" size="8" /></p>',
  365. )
  366. +class AdminURLWidgetTest(DjangoTestCase):
  367. + def test_render(self):
  368. + w = widgets.AdminURLFieldWidget()
  369. + self.assertHTMLEqual(
  370. + conditional_escape(w.render('test', '')),
  371. + '<input class="vURLField" name="test" type="text" />'
  372. + )
  373. + self.assertHTMLEqual(
  374. + conditional_escape(w.render('test', 'http://example.com')),
  375. + '<p class="url">Currently:<a href="http://example.com">http://example.com</a><br />Change:<input class="vURLField" name="test" type="text" value="http://example.com" /></p>'
  376. + )
  377. +
  378. + def test_render_idn(self):
  379. + w = widgets.AdminURLFieldWidget()
  380. + self.assertHTMLEqual(
  381. + conditional_escape(w.render('test', 'http://example-äüö.com')),
  382. + '<p class="url">Currently:<a href="http://xn--example--7za4pnc.com">http://example-äüö.com</a><br />Change:<input class="vURLField" name="test" type="text" value="http://example-äüö.com" /></p>'
  383. + )
  384. +
  385. + def test_render_quoting(self):
  386. + w = widgets.AdminURLFieldWidget()
  387. + self.assertHTMLEqual(
  388. + conditional_escape(w.render('test', 'http://example.com/<sometag>some text</sometag>')),
  389. + '<p class="url">Currently:<a href="http://example.com/%3Csometag%3Esome%20text%3C/sometag%3E">http://example.com/&lt;sometag&gt;some text&lt;/sometag&gt;</a><br />Change:<input class="vURLField" name="test" type="text" value="http://example.com/<sometag>some text</sometag>" /></p>'
  390. + )
  391. + self.assertHTMLEqual(
  392. + conditional_escape(w.render('test', 'http://example-äüö.com/<sometag>some text</sometag>')),
  393. + '<p class="url">Currently:<a href="http://xn--example--7za4pnc.com/%3Csometag%3Esome%20text%3C/sometag%3E">http://example-äüö.com/&lt;sometag&gt;some text&lt;/sometag&gt;</a><br />Change:<input class="vURLField" name="test" type="text" value="http://example-äüö.com/<sometag>some text</sometag>" /></p>'
  394. + )
  395. class AdminFileWidgetTest(DjangoTestCase):
  396. def test_render(self):
  397. So what do I do next?
  398. =====================
  399. Congratulations, you've generated your very first Django patch! Now that you've
  400. got that under your belt, you can put those skills to good use by helping to
  401. improve Django's codebase. Generating patches and attaching them to Trac
  402. tickets is useful, however, since we are using git - adopting a more :doc:`git
  403. oriented workflow </internals/contributing/writing-code/working-with-git>` is
  404. recommended.
  405. Since we never committed our changes locally, perform the following to get your
  406. git branch back to a good starting point::
  407. git reset --hard HEAD
  408. git checkout master
  409. More information for new contributors
  410. -------------------------------------
  411. Before you get too into writing patches for Django, there's a little more
  412. information on contributing that you should probably take a look at:
  413. * You should make sure to read Django's documentation on
  414. :doc:`claiming tickets and submitting patches
  415. </internals/contributing/writing-code/submitting-patches>`.
  416. It covers Trac etiquette, how to claim tickets for yourself, expected
  417. coding style for patches, and many other important details.
  418. * First time contributors should also read Django's :doc:`documentation
  419. for first time contributors</internals/contributing/new-contributors/>`.
  420. It has lots of good advice for those of us who are new to helping out
  421. with Django.
  422. * After those, if you're still hungry for more information about
  423. contributing, you can always browse through the rest of
  424. :doc:`Django's documentation on contributing</internals/contributing/index>`.
  425. It contains a ton of useful information and should be your first source
  426. for answering any questions you might have.
  427. Finding your first real ticket
  428. ------------------------------
  429. Once you've looked through some of that information, you'll be ready to go out
  430. and find a ticket of your own to write a patch for. Pay special attention to
  431. tickets with the "easy pickings" criterion. These tickets are often much
  432. simpler in nature and are great for first time contributors. Once you're
  433. familiar with contributing to Django, you can move on to writing patches for
  434. more difficult and complicated tickets.
  435. If you just want to get started already (and nobody would blame you!), try
  436. taking a look at the list of `easy tickets that need patches`__ and the
  437. `easy tickets that have patches which need improvement`__. If you're familiar
  438. with writing tests, you can also look at the list of
  439. `easy tickets that need tests`__. Just remember to follow the guidelines about
  440. claiming tickets that were mentioned in the link to Django's documentation on
  441. :doc:`claiming tickets and submitting patches
  442. </internals/contributing/writing-code/submitting-patches>`.
  443. __ 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
  444. __ 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
  445. __ 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
  446. What's next?
  447. ------------
  448. After a ticket has a patch, it needs to be reviewed by a second set of eyes.
  449. After uploading a patch or submitting a pull request, be sure to update the
  450. ticket metadata by setting the flags on the ticket to say "has patch",
  451. "doesn't need tests", etc, so others can find it for review. Contributing
  452. doesn't necessarily always mean writing a patch from scratch. Reviewing
  453. existing patches is also a very helpful contribution. See
  454. :doc:`/internals/contributing/triaging-tickets` for details.