contributing.txt 27 KB

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