contributing.txt 27 KB

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