contributing.txt 27 KB

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