contributing.txt 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  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" (for `Python 2`__, for `Python 3`__) is a fantastic
  19. (and free) online book for beginning 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://diveintopython3.net/
  32. __ http://groups.google.com/group/django-developers
  33. __ irc://irc.freenode.net/django-dev
  34. What does this tutorial cover?
  35. ------------------------------
  36. We'll be walking you through contributing a patch to Django for the first time.
  37. By the end of this tutorial, you should have a basic understanding of both the
  38. tools and the processes involved. Specifically, we'll be covering the following:
  39. * Installing Git.
  40. * How to download a development copy of Django.
  41. * Running Django's test suite.
  42. * Writing a test for your patch.
  43. * Writing the code for your patch.
  44. * Testing your patch.
  45. * Generating a patch file for your changes.
  46. * Where to look for more information.
  47. Once you're done with the tutorial, you can look through the rest of
  48. :doc:`Django's documentation on contributing</internals/contributing/index>`.
  49. It contains lots of great information and is a must read for anyone who'd like
  50. to become a regular contributor to Django. If you've got questions, it's
  51. probably got the answers.
  52. Installing Git
  53. ==============
  54. For this tutorial, you'll need Git installed to download the current
  55. development version of Django and to generate patch files for the changes you
  56. make.
  57. To check whether or not you have Git installed, enter ``git`` into the command
  58. line. If you get messages saying that this command could be found, you'll have
  59. to download and install it, see `Git's download page`__.
  60. If you're not that familiar with Git, you can always find out more about its
  61. commands (once it's installed) by typing ``git help`` into the command line.
  62. __ http://git-scm.com/download
  63. Getting a copy of Django's development version
  64. ==============================================
  65. The first step to contributing to Django is to get a copy of the source code.
  66. From the command line, use the ``cd`` command to navigate to the directory
  67. where you'll want your local copy of Django to live.
  68. Download the Django source code repository using the following command::
  69. git clone https://github.com/django/django.git
  70. .. note::
  71. For users who wish to use `virtualenv`__, you can use::
  72. pip install -e /path/to/your/local/clone/django/
  73. (where ``django`` is the directory of your clone that contains
  74. ``setup.py``) to link your cloned checkout into a virtual environment. This
  75. is a great option to isolate your development copy of Django from the rest
  76. of your system and avoids potential package conflicts.
  77. __ http://www.virtualenv.org
  78. Rolling back to a previous revision of Django
  79. =============================================
  80. For this tutorial, we'll be using `ticket #17549`__ as a case study, so we'll
  81. rewind Django's version history in git to before that ticket's patch was
  82. applied. This will allow us to go through all of the steps involved in writing
  83. that patch from scratch, including running Django's test suite.
  84. **Keep in mind that while we'll be using an older revision of Django's trunk
  85. for the purposes of the tutorial below, you should always use the current
  86. development revision of Django when working on your own patch for a ticket!**
  87. .. note::
  88. The patch for this ticket was written by Ulrich Petri, and it was applied
  89. to Django as `commit ac2052ebc84c45709ab5f0f25e685bf656ce79bc`__.
  90. Consequently, we'll be using the revision of Django just prior to that,
  91. `commit 39f5bc7fc3a4bb43ed8a1358b17fe0521a1a63ac`__.
  92. __ https://code.djangoproject.com/ticket/17549
  93. __ https://github.com/django/django/commit/ac2052ebc84c45709ab5f0f25e685bf656ce79bc
  94. __ https://github.com/django/django/commit/39f5bc7fc3a4bb43ed8a1358b17fe0521a1a63ac
  95. Navigate into Django's root directory (that's the one that contains ``django``,
  96. ``docs``, ``tests``, ``AUTHORS``, etc.). You can then check out the older
  97. revision of Django that we'll be using in the tutorial below::
  98. git checkout 39f5bc7fc3a4bb43ed8a1358b17fe0521a1a63ac
  99. Running Django's test suite for the first time
  100. ==============================================
  101. When contributing to Django it's very important that your code changes don't
  102. introduce bugs into other areas of Django. One way to check that Django still
  103. works after you make your changes is by running Django's test suite. If all
  104. the tests still pass, then you can be reasonably sure that your changes
  105. haven't completely broken Django. If you've never run Django's test suite
  106. before, it's a good idea to run it once beforehand just to get familiar with
  107. what its output is supposed to look like.
  108. We can run the test suite by simply ``cd``-ing into the Django ``tests/``
  109. directory and, if you're using GNU/Linux, Mac OS X or some other flavor of
  110. Unix, run::
  111. PYTHONPATH=.. python runtests.py --settings=test_sqlite
  112. If you're on Windows, the above should work provided that you are using
  113. "Git Bash" provided by the default Git install. GitHub has a `nice tutorial`__.
  114. __ https://help.github.com/articles/set-up-git#platform-windows
  115. .. note::
  116. If you're using ``virtualenv``, you can omit ``PYTHONPATH=..`` when running
  117. the tests. This instructs Python to look for Django in the parent directory
  118. of ``tests``. ``virtualenv`` puts your copy of Django on the ``PYTHONPATH``
  119. automatically.
  120. Now sit back and relax. Django's entire test suite has over 4800 different
  121. tests, so it can take anywhere from 5 to 15 minutes to run, depending on the
  122. speed of your computer.
  123. While Django's test suite is running, you'll see a stream of characters
  124. representing the status of each test as it's run. ``E`` indicates that an error
  125. was raised during a test, and ``F`` indicates that a test's assertions failed.
  126. Both of these are considered to be test failures. Meanwhile, ``x`` and ``s``
  127. indicated expected failures and skipped tests, respectively. Dots indicate
  128. passing tests.
  129. Skipped tests are typically due to missing external libraries required to run
  130. the test; see :ref:`running-unit-tests-dependencies` for a list of dependencies
  131. and be sure to install any for tests related to the changes you are making (we
  132. won't need any for this tutorial).
  133. Once the tests complete, you should be greeted with a message informing you
  134. whether the test suite passed or failed. Since you haven't yet made any changes
  135. to Django's code, the entire test suite **should** pass. If you get failures or
  136. errors make sure you've followed all of the previous steps properly. See
  137. :ref:`running-unit-tests` for more information.
  138. Note that the latest Django trunk may not always be stable. When developing
  139. against trunk, you can check `Django's continuous integration builds`__ to
  140. determine if the failures are specific to your machine or if they are also
  141. present in Django's official builds. If you click to view a particular build,
  142. you can view the "Configuration Matrix" which shows failures broken down by
  143. Python version and database backend.
  144. __ http://ci.djangoproject.com/
  145. .. note::
  146. For this tutorial and the ticket we're working on, testing against SQLite
  147. is sufficient, however, it's possible (and sometimes necessary) to
  148. :ref:`run the tests using a different database
  149. <running-unit-tests-settings>`.
  150. Writing some tests for your ticket
  151. ==================================
  152. In most cases, for a patch to be accepted into Django it has to include tests.
  153. For bug fix patches, this means writing a regression test to ensure that the
  154. bug is never reintroduced into Django later on. A regression test should be
  155. written in such a way that it will fail while the bug still exists and pass
  156. once the bug has been fixed. For patches containing new features, you'll need
  157. to include tests which ensure that the new features are working correctly.
  158. They too should fail when the new feature is not present, and then pass once it
  159. has been implemented.
  160. A good way to do this is to write your new tests first, before making any
  161. changes to the code. This style of development is called
  162. `test-driven development`__ and can be applied to both entire projects and
  163. single patches. After writing your tests, you then run them to make sure that
  164. they do indeed fail (since you haven't fixed that bug or added that feature
  165. yet). If your new tests don't fail, you'll need to fix them so that they do.
  166. After all, a regression test that passes regardless of whether a bug is present
  167. is not very helpful at preventing that bug from reoccurring down the road.
  168. Now for our hands-on example.
  169. __ http://en.wikipedia.org/wiki/Test-driven_development
  170. Writing some tests for ticket #17549
  171. ------------------------------------
  172. `Ticket #17549`__ describes the following, small feature addition:
  173. It's useful for URLField to give you a way to open the URL; otherwise you
  174. might as well use a CharField.
  175. In order to resolve this ticket, we'll add a ``render`` method to the
  176. ``AdminURLFieldWidget`` in order to display a clickable link above the input
  177. widget. Before we make those changes though, we're going to write a couple
  178. tests to verify that our modification functions correctly and continues to
  179. function correctly in the future.
  180. Navigate to Django's ``tests/admin_widgets/`` folder and
  181. open the ``tests.py`` file. Add the following code on line 269 right before the
  182. ``AdminFileWidgetTest`` class::
  183. class AdminURLWidgetTest(DjangoTestCase):
  184. def test_render(self):
  185. w = widgets.AdminURLFieldWidget()
  186. self.assertHTMLEqual(
  187. conditional_escape(w.render('test', '')),
  188. '<input class="vURLField" name="test" type="text" />'
  189. )
  190. self.assertHTMLEqual(
  191. conditional_escape(w.render('test', 'http://example.com')),
  192. '<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>'
  193. )
  194. def test_render_idn(self):
  195. w = widgets.AdminURLFieldWidget()
  196. self.assertHTMLEqual(
  197. conditional_escape(w.render('test', 'http://example-äüö.com')),
  198. '<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>'
  199. )
  200. def test_render_quoting(self):
  201. w = widgets.AdminURLFieldWidget()
  202. self.assertHTMLEqual(
  203. conditional_escape(w.render('test', 'http://example.com/<sometag>some text</sometag>')),
  204. '<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>'
  205. )
  206. self.assertHTMLEqual(
  207. conditional_escape(w.render('test', 'http://example-äüö.com/<sometag>some text</sometag>')),
  208. '<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>'
  209. )
  210. The new tests check to see that the ``render`` method we'll be adding works
  211. correctly in a couple different situations.
  212. .. admonition:: But this testing thing looks kinda hard...
  213. If you've never had to deal with tests before, they can look a little hard
  214. to write at first glance. Fortunately, testing is a *very* big subject in
  215. computer programming, so there's lots of information out there:
  216. * A good first look at writing tests for Django can be found in the
  217. documentation on :doc:`Testing Django applications </topics/testing/overview>`.
  218. * Dive Into Python (a free online book for beginning Python developers)
  219. includes a great `introduction to Unit Testing`__.
  220. * After reading those, if you want something a little meatier to sink
  221. your teeth into, there's always the `Python unittest documentation`__.
  222. __ https://code.djangoproject.com/ticket/17549
  223. __ http://diveintopython.net/unit_testing/index.html
  224. __ http://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 #17549`__ to Django.
  240. Writing the code for ticket #17549
  241. ----------------------------------
  242. Navigate to the ``django/django/contrib/admin/`` folder and open the
  243. ``widgets.py`` file. Find the ``AdminURLFieldWidget`` class on line 302 and add
  244. the following ``render`` method after the existing ``__init__`` method::
  245. def render(self, name, value, attrs=None):
  246. html = super(AdminURLFieldWidget, self).render(name, value, attrs)
  247. if value:
  248. value = force_text(self._format_value(value))
  249. final_attrs = {'href': mark_safe(smart_urlquote(value))}
  250. html = format_html(
  251. '<p class="url">{0} <a {1}>{2}</a><br />{3} {4}</p>',
  252. _('Currently:'), flatatt(final_attrs), value,
  253. _('Change:'), html
  254. )
  255. return html
  256. Verifying your test now passes
  257. ------------------------------
  258. Once you're done modifying Django, we need to make sure that the tests we wrote
  259. earlier pass, so we can see whether the code we wrote above is working
  260. correctly. To run the tests in the ``admin_widgets`` folder, ``cd`` into the
  261. Django ``tests/`` directory and run::
  262. PYTHONPATH=.. python runtests.py --settings=test_sqlite admin_widgets
  263. Oops, good thing we wrote those tests! You should still see 3 failures with
  264. the following exception::
  265. NameError: global name 'smart_urlquote' is not defined
  266. We forgot to add the import for that method. Go ahead and add the
  267. ``smart_urlquote`` import at the end of line 13 of
  268. ``django/contrib/admin/widgets.py`` so it looks as follows::
  269. from django.utils.html import escape, format_html, format_html_join, smart_urlquote
  270. Re-run the tests and everything should pass. If it doesn't, make sure you
  271. correctly modified the ``AdminURLFieldWidget`` class as shown above and
  272. copied the new tests correctly.
  273. __ https://code.djangoproject.com/ticket/17549
  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">{0} <a {1}>{2}</a><br />{3} {4}</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/admin_widgets/tests.py b/tests/admin_widgets/tests.py
  361. index 4b11543..94acc6d 100644
  362. --- a/tests/admin_widgets/tests.py
  363. +++ b/tests/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.