contributing.txt 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  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. * Submitting a pull request.
  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. .. admonition:: Python 3 required!
  55. The current version of Django doesn't support Python 2.7. Get Python 3 at
  56. `Python's download page <https://www.python.org/downloads/>`_ or with your
  57. operating system's package manager.
  58. .. admonition:: For Windows users
  59. When installing Python on Windows, make sure you check the option "Add
  60. python.exe to Path", so that it is always available on the command line.
  61. Code of Conduct
  62. ===============
  63. As a contributor, you can help us keep the Django community open and inclusive.
  64. Please read and follow our `Code of Conduct <https://www.djangoproject.com/conduct/>`_.
  65. Installing Git
  66. ==============
  67. For this tutorial, you'll need Git installed to download the current
  68. development version of Django and to generate patch files for the changes you
  69. make.
  70. To check whether or not you have Git installed, enter ``git`` into the command
  71. line. If you get messages saying that this command could not be found, you'll
  72. have to download and install it, see `Git's download page`__.
  73. If you're not that familiar with Git, you can always find out more about its
  74. commands (once it's installed) by typing ``git help`` into the command line.
  75. __ https://git-scm.com/download
  76. Getting a copy of Django's development version
  77. ==============================================
  78. The first step to contributing to Django is to get a copy of the source code.
  79. First, `fork Django on GitHub <https://github.com/django/django/fork>`__. Then,
  80. from the command line, use the ``cd`` command to navigate to the directory
  81. where you'll want your local copy of Django to live.
  82. Download the Django source code repository using the following command:
  83. .. console::
  84. $ git clone git@github.com:YourGitHubName/django.git
  85. Now that you have a local copy of Django, you can install it just like you would
  86. install any package using ``pip``. The most convenient way to do so is by using
  87. a *virtual environment* (or virtualenv) which is a feature built into Python
  88. that allows you to keep a separate directory of installed packages for each of
  89. your projects so that they don't interfere with each other.
  90. It's a good idea to keep all your virtualenvs in one place, for example in
  91. ``.virtualenvs/`` in your home directory. Create it if it doesn't exist yet:
  92. .. console::
  93. $ mkdir ~/.virtualenvs
  94. Now create a new virtualenv by running:
  95. .. console::
  96. $ python -m venv ~/.virtualenvs/djangodev
  97. The path is where the new environment will be saved on your computer.
  98. .. admonition:: For Ubuntu users
  99. On some versions of Ubuntu the above command might fail. Use the
  100. ``virtualenv`` package instead, first making sure you have ``pip3``:
  101. .. code-block:: console
  102. $ sudo apt-get install python3-pip
  103. $ # Prefix the next command with sudo if it gives a permission denied error
  104. $ pip3 install virtualenv
  105. $ virtualenv --python=`which python3` ~/.virtualenvs/djangodev
  106. The final step in setting up your virtualenv is to activate it:
  107. .. code-block:: console
  108. $ source ~/.virtualenvs/djangodev/bin/activate
  109. If the ``source`` command is not available, you can try using a dot instead:
  110. .. code-block:: console
  111. $ . ~/.virtualenvs/djangodev/bin/activate
  112. .. admonition:: For Windows users
  113. To activate your virtualenv on Windows, run:
  114. .. code-block:: doscon
  115. ...\> %HOMEPATH%\.virtualenvs\djangodev\Scripts\activate.bat
  116. You have to activate the virtualenv whenever you open a new terminal window.
  117. virtualenvwrapper__ is a useful tool for making this more convenient.
  118. __ https://virtualenvwrapper.readthedocs.io/en/latest/
  119. Anything you install through ``pip`` from now on will be installed in your new
  120. virtualenv, isolated from other environments and system-wide packages. Also, the
  121. name of the currently activated virtualenv is displayed on the command line to
  122. help you keep track of which one you are using. Go ahead and install the
  123. previously cloned copy of Django:
  124. .. console::
  125. $ pip install -e /path/to/your/local/clone/django/
  126. The installed version of Django is now pointing at your local copy. You will
  127. immediately see any changes you make to it, which is of great help when writing
  128. your first patch.
  129. Rolling back to a previous revision of Django
  130. =============================================
  131. For this tutorial, we'll be using ticket :ticket:`24788` as a case study, so
  132. we'll rewind Django's version history in git to before that ticket's patch was
  133. applied. This will allow us to go through all of the steps involved in writing
  134. that patch from scratch, including running Django's test suite.
  135. **Keep in mind that while we'll be using an older revision of Django for this
  136. tutorial, you should always use the current version of the master branch when
  137. working on your own patch for a ticket!**
  138. .. note::
  139. The patch for this ticket was written by Paweł Marczewski, and it was
  140. applied to Django as `commit 4df7e8483b2679fc1cba3410f08960bac6f51115`__.
  141. Consequently, we'll be using the revision of Django just prior to that,
  142. `commit 4ccfc4439a7add24f8db4ef3960d02ef8ae09887`__.
  143. __ https://github.com/django/django/commit/4df7e8483b2679fc1cba3410f08960bac6f51115
  144. __ https://github.com/django/django/commit/4ccfc4439a7add24f8db4ef3960d02ef8ae09887
  145. Navigate into Django's root directory (that's the one that contains ``django``,
  146. ``docs``, ``tests``, ``AUTHORS``, etc.). You can then check out the older
  147. revision of Django that we'll be using in the tutorial below:
  148. .. console::
  149. $ git checkout 4ccfc4439a7add24f8db4ef3960d02ef8ae09887
  150. Running Django's test suite for the first time
  151. ==============================================
  152. When contributing to Django it's very important that your code changes don't
  153. introduce bugs into other areas of Django. One way to check that Django still
  154. works after you make your changes is by running Django's test suite. If all
  155. the tests still pass, then you can be reasonably sure that your changes
  156. haven't completely broken Django. If you've never run Django's test suite
  157. before, it's a good idea to run it once beforehand just to get familiar with
  158. what its output is supposed to look like.
  159. Before running the test suite, install its dependencies by first ``cd``-ing
  160. into the Django ``tests/`` directory and then running:
  161. .. console::
  162. $ pip install -r requirements/py3.txt
  163. If you encounter an error during the installation, your system might be missing
  164. a dependency for one or more of the Python packages. Consult the failing
  165. package's documentation or search the Web with the error message that you
  166. encounter.
  167. Now we are ready to run the test suite. If you're using GNU/Linux, macOS, or
  168. some other flavor of Unix, run:
  169. .. console::
  170. $ ./runtests.py
  171. Now sit back and relax. Django's entire test suite has over 9,600 different
  172. tests, so it can take anywhere from 5 to 15 minutes to run, depending on the
  173. speed of your computer.
  174. While Django's test suite is running, you'll see a stream of characters
  175. representing the status of each test as it's run. ``E`` indicates that an error
  176. was raised during a test, and ``F`` indicates that a test's assertions failed.
  177. Both of these are considered to be test failures. Meanwhile, ``x`` and ``s``
  178. indicated expected failures and skipped tests, respectively. Dots indicate
  179. passing tests.
  180. Skipped tests are typically due to missing external libraries required to run
  181. the test; see :ref:`running-unit-tests-dependencies` for a list of dependencies
  182. and be sure to install any for tests related to the changes you are making (we
  183. won't need any for this tutorial). Some tests are specific to a particular
  184. database backend and will be skipped if not testing with that backend. SQLite
  185. is the database backend for the default settings. To run the tests using a
  186. different backend, see :ref:`running-unit-tests-settings`.
  187. Once the tests complete, you should be greeted with a message informing you
  188. whether the test suite passed or failed. Since you haven't yet made any changes
  189. to Django's code, the entire test suite **should** pass. If you get failures or
  190. errors make sure you've followed all of the previous steps properly. See
  191. :ref:`running-unit-tests` for more information. There will be a couple failures
  192. related to deprecation warnings that you can ignore. These failures have since
  193. been fixed in Django.
  194. Note that the latest Django master may not always be stable. When developing
  195. against master, you can check `Django's continuous integration builds`__ to
  196. determine if the failures are specific to your machine or if they are also
  197. present in Django's official builds. If you click to view a particular build,
  198. you can view the "Configuration Matrix" which shows failures broken down by
  199. Python version and database backend.
  200. __ https://djangoci.com
  201. .. note::
  202. For this tutorial and the ticket we're working on, testing against SQLite
  203. is sufficient, however, it's possible (and sometimes necessary) to
  204. :ref:`run the tests using a different database
  205. <running-unit-tests-settings>`.
  206. Creating a branch for your patch
  207. ================================
  208. Before making any changes, create a new branch for the ticket:
  209. .. console::
  210. $ git checkout -b ticket_24788
  211. You can choose any name that you want for the branch, "ticket_24788" is an
  212. example. All changes made in this branch will be specific to the ticket and
  213. won't affect the main copy of the code that we cloned earlier.
  214. Writing some tests for your ticket
  215. ==================================
  216. In most cases, for a patch to be accepted into Django it has to include tests.
  217. For bug fix patches, this means writing a regression test to ensure that the
  218. bug is never reintroduced into Django later on. A regression test should be
  219. written in such a way that it will fail while the bug still exists and pass
  220. once the bug has been fixed. For patches containing new features, you'll need
  221. to include tests which ensure that the new features are working correctly.
  222. They too should fail when the new feature is not present, and then pass once it
  223. has been implemented.
  224. A good way to do this is to write your new tests first, before making any
  225. changes to the code. This style of development is called
  226. `test-driven development`__ and can be applied to both entire projects and
  227. single patches. After writing your tests, you then run them to make sure that
  228. they do indeed fail (since you haven't fixed that bug or added that feature
  229. yet). If your new tests don't fail, you'll need to fix them so that they do.
  230. After all, a regression test that passes regardless of whether a bug is present
  231. is not very helpful at preventing that bug from reoccurring down the road.
  232. Now for our hands-on example.
  233. __ https://en.wikipedia.org/wiki/Test-driven_development
  234. Writing some tests for ticket #24788
  235. ------------------------------------
  236. Ticket :ticket:`24788` proposes a small feature addition: the ability to
  237. specify the class level attribute ``prefix`` on Form classes, so that::
  238. […] forms which ship with apps could effectively namespace themselves such
  239. that N overlapping form fields could be POSTed at once and resolved to the
  240. correct form.
  241. In order to resolve this ticket, we'll add a ``prefix`` attribute to the
  242. ``BaseForm`` class. When creating instances of this class, passing a prefix to
  243. the ``__init__()`` method will still set that prefix on the created instance.
  244. But not passing a prefix (or passing ``None``) will use the class-level prefix.
  245. Before we make those changes though, we're going to write a couple tests to
  246. verify that our modification functions correctly and continues to function
  247. correctly in the future.
  248. Navigate to Django's ``tests/forms_tests/tests/`` folder and open the
  249. ``test_forms.py`` file. Add the following code on line 1674 right before the
  250. ``test_forms_with_null_boolean`` function::
  251. def test_class_prefix(self):
  252. # Prefix can be also specified at the class level.
  253. class Person(Form):
  254. first_name = CharField()
  255. prefix = 'foo'
  256. p = Person()
  257. self.assertEqual(p.prefix, 'foo')
  258. p = Person(prefix='bar')
  259. self.assertEqual(p.prefix, 'bar')
  260. This new test checks that setting a class level prefix works as expected, and
  261. that passing a ``prefix`` parameter when creating an instance still works too.
  262. .. admonition:: But this testing thing looks kinda hard...
  263. If you've never had to deal with tests before, they can look a little hard
  264. to write at first glance. Fortunately, testing is a *very* big subject in
  265. computer programming, so there's lots of information out there:
  266. * A good first look at writing tests for Django can be found in the
  267. documentation on :doc:`/topics/testing/overview`.
  268. * Dive Into Python (a free online book for beginning Python developers)
  269. includes a great `introduction to Unit Testing`__.
  270. * After reading those, if you want something a little meatier to sink
  271. your teeth into, there's always the Python :mod:`unittest` documentation.
  272. __ http://www.diveintopython3.net/unit-testing.html
  273. Running your new test
  274. ---------------------
  275. Remember that we haven't actually made any modifications to ``BaseForm`` yet,
  276. so our tests are going to fail. Let's run all the tests in the ``forms_tests``
  277. folder to make sure that's really what happens. From the command line, ``cd``
  278. into the Django ``tests/`` directory and run:
  279. .. console::
  280. $ ./runtests.py forms_tests
  281. If the tests ran correctly, you should see one failure corresponding to the test
  282. method we added. If all of the tests passed, then you'll want to make sure that
  283. you added the new test shown above to the appropriate folder and class.
  284. Writing the code for your ticket
  285. ================================
  286. Next we'll be adding the functionality described in ticket :ticket:`24788` to
  287. Django.
  288. Writing the code for ticket #24788
  289. ----------------------------------
  290. Navigate to the ``django/django/forms/`` folder and open the ``forms.py`` file.
  291. Find the ``BaseForm`` class on line 72 and add the ``prefix`` class attribute
  292. right after the ``field_order`` attribute::
  293. class BaseForm:
  294. # This is the main implementation of all the Form logic. Note that this
  295. # class is different than Form. See the comments by the Form class for
  296. # more information. Any improvements to the form API should be made to
  297. # *this* class, not to the Form class.
  298. field_order = None
  299. prefix = None
  300. Verifying your test now passes
  301. ------------------------------
  302. Once you're done modifying Django, we need to make sure that the tests we wrote
  303. earlier pass, so we can see whether the code we wrote above is working
  304. correctly. To run the tests in the ``forms_tests`` folder, ``cd`` into the
  305. Django ``tests/`` directory and run:
  306. .. console::
  307. $ ./runtests.py forms_tests
  308. Oops, good thing we wrote those tests! You should still see one failure with
  309. the following exception::
  310. AssertionError: None != 'foo'
  311. We forgot to add the conditional statement in the ``__init__`` method. Go ahead
  312. and change ``self.prefix = prefix`` that is now on line 87 of
  313. ``django/forms/forms.py``, adding a conditional statement::
  314. if prefix is not None:
  315. self.prefix = prefix
  316. Re-run the tests and everything should pass. If it doesn't, make sure you
  317. correctly modified the ``BaseForm`` class as shown above and copied the new test
  318. correctly.
  319. Running Django's test suite for the second time
  320. ===============================================
  321. Once you've verified that your patch and your test are working correctly, it's
  322. a good idea to run the entire Django test suite just to verify that your change
  323. hasn't introduced any bugs into other areas of Django. While successfully
  324. passing the entire test suite doesn't guarantee your code is bug free, it does
  325. help identify many bugs and regressions that might otherwise go unnoticed.
  326. To run the entire Django test suite, ``cd`` into the Django ``tests/``
  327. directory and run:
  328. .. console::
  329. $ ./runtests.py
  330. As long as you don't see any failures, you're good to go.
  331. Writing Documentation
  332. =====================
  333. This is a new feature, so it should be documented. Add the following section on
  334. line 1068 (at the end of the file) of ``django/docs/ref/forms/api.txt``::
  335. The prefix can also be specified on the form class::
  336. >>> class PersonForm(forms.Form):
  337. ... ...
  338. ... prefix = 'person'
  339. .. versionadded:: 1.9
  340. The ability to specify ``prefix`` on the form class was added.
  341. Since this new feature will be in an upcoming release it is also added to the
  342. release notes for Django 1.9, on line 164 under the "Forms" section in the file
  343. ``docs/releases/1.9.txt``::
  344. * A form prefix can be specified inside a form class, not only when
  345. instantiating a form. See :ref:`form-prefix` for details.
  346. For more information on writing documentation, including an explanation of what
  347. the ``versionadded`` bit is all about, see
  348. :doc:`/internals/contributing/writing-documentation`. That page also includes
  349. an explanation of how to build a copy of the documentation locally, so you can
  350. preview the HTML that will be generated.
  351. Previewing your changes
  352. =======================
  353. Now it's time to go through all the changes made in our patch. To display the
  354. differences between your current copy of Django (with your changes) and the
  355. revision that you initially checked out earlier in the tutorial:
  356. .. console::
  357. $ git diff
  358. Use the arrow keys to move up and down.
  359. .. code-block:: diff
  360. diff --git a/django/forms/forms.py b/django/forms/forms.py
  361. index 509709f..d1370de 100644
  362. --- a/django/forms/forms.py
  363. +++ b/django/forms/forms.py
  364. @@ -75,6 +75,7 @@ class BaseForm:
  365. # information. Any improvements to the form API should be made to *this*
  366. # class, not to the Form class.
  367. field_order = None
  368. + prefix = None
  369. def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
  370. initial=None, error_class=ErrorList, label_suffix=None,
  371. @@ -83,7 +84,8 @@ class BaseForm:
  372. self.data = data or {}
  373. self.files = files or {}
  374. self.auto_id = auto_id
  375. - self.prefix = prefix
  376. + if prefix is not None:
  377. + self.prefix = prefix
  378. self.initial = initial or {}
  379. self.error_class = error_class
  380. # Translators: This is the default suffix added to form field labels
  381. diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt
  382. index 3bc39cd..008170d 100644
  383. --- a/docs/ref/forms/api.txt
  384. +++ b/docs/ref/forms/api.txt
  385. @@ -1065,3 +1065,13 @@ You can put several Django forms inside one ``<form>`` tag. To give each
  386. >>> print(father.as_ul())
  387. <li><label for="id_father-first_name">First name:</label> <input type="text" name="father-first_name" id="id_father-first_name"></li>
  388. <li><label for="id_father-last_name">Last name:</label> <input type="text" name="father-last_name" id="id_father-last_name"></li>
  389. +
  390. +The prefix can also be specified on the form class::
  391. +
  392. + >>> class PersonForm(forms.Form):
  393. + ... ...
  394. + ... prefix = 'person'
  395. +
  396. +.. versionadded:: 1.9
  397. +
  398. + The ability to specify ``prefix`` on the form class was added.
  399. diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt
  400. index 5b58f79..f9bb9de 100644
  401. --- a/docs/releases/1.9.txt
  402. +++ b/docs/releases/1.9.txt
  403. @@ -161,6 +161,9 @@ Forms
  404. :attr:`~django.forms.Form.field_order` attribute, the ``field_order``
  405. constructor argument , or the :meth:`~django.forms.Form.order_fields` method.
  406. +* A form prefix can be specified inside a form class, not only when
  407. + instantiating a form. See :ref:`form-prefix` for details.
  408. +
  409. Generic Views
  410. ^^^^^^^^^^^^^
  411. diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
  412. index 690f205..e07fae2 100644
  413. --- a/tests/forms_tests/tests/test_forms.py
  414. +++ b/tests/forms_tests/tests/test_forms.py
  415. @@ -1671,6 +1671,18 @@ class FormsTestCase(SimpleTestCase):
  416. self.assertEqual(p.cleaned_data['last_name'], 'Lennon')
  417. self.assertEqual(p.cleaned_data['birthday'], datetime.date(1940, 10, 9))
  418. + def test_class_prefix(self):
  419. + # Prefix can be also specified at the class level.
  420. + class Person(Form):
  421. + first_name = CharField()
  422. + prefix = 'foo'
  423. +
  424. + p = Person()
  425. + self.assertEqual(p.prefix, 'foo')
  426. +
  427. + p = Person(prefix='bar')
  428. + self.assertEqual(p.prefix, 'bar')
  429. +
  430. def test_forms_with_null_boolean(self):
  431. # NullBooleanField is a bit of a special case because its presentation (widget)
  432. # is different than its data. This is handled transparently, though.
  433. When you're done previewing the patch, hit the ``q`` key to return to the
  434. command line. If the patch's content looked okay, it's time to commit the
  435. changes.
  436. Committing the changes in the patch
  437. ===================================
  438. To commit the changes:
  439. .. console::
  440. $ git commit -a
  441. This opens up a text editor to type the commit message. Follow the :ref:`commit
  442. message guidelines <committing-guidelines>` and write a message like:
  443. .. code-block:: text
  444. Fixed #24788 -- Allowed Forms to specify a prefix at the class level.
  445. Pushing the commit and making a pull request
  446. ============================================
  447. After committing the patch, send it to your fork on GitHub (substitute
  448. "ticket_24788" with the name of your branch if it's different):
  449. .. console::
  450. $ git push origin ticket_24788
  451. You can create a pull request by visiting the `Django GitHub page
  452. <https://github.com/django/django/>`_. You'll see your branch under "Your
  453. recently pushed branches". Click "Compare & pull request" next to it.
  454. Please don't do it for this tutorial, but on the next page that displays a
  455. preview of the patch, you would click "Create pull request".
  456. Next steps
  457. ==========
  458. Congratulations, you've learned how to make a pull request to Django! Details
  459. of more advanced techniques you may need are in
  460. :doc:`/internals/contributing/writing-code/working-with-git`.
  461. Now you can put those skills to good use by helping to improve Django's
  462. codebase.
  463. More information for new contributors
  464. -------------------------------------
  465. Before you get too into writing patches for Django, there's a little more
  466. information on contributing that you should probably take a look at:
  467. * You should make sure to read Django's documentation on
  468. :doc:`claiming tickets and submitting patches
  469. </internals/contributing/writing-code/submitting-patches>`.
  470. It covers Trac etiquette, how to claim tickets for yourself, expected
  471. coding style for patches, and many other important details.
  472. * First time contributors should also read Django's :doc:`documentation
  473. for first time contributors</internals/contributing/new-contributors/>`.
  474. It has lots of good advice for those of us who are new to helping out
  475. with Django.
  476. * After those, if you're still hungry for more information about
  477. contributing, you can always browse through the rest of
  478. :doc:`Django's documentation on contributing</internals/contributing/index>`.
  479. It contains a ton of useful information and should be your first source
  480. for answering any questions you might have.
  481. Finding your first real ticket
  482. ------------------------------
  483. Once you've looked through some of that information, you'll be ready to go out
  484. and find a ticket of your own to write a patch for. Pay special attention to
  485. tickets with the "easy pickings" criterion. These tickets are often much
  486. simpler in nature and are great for first time contributors. Once you're
  487. familiar with contributing to Django, you can move on to writing patches for
  488. more difficult and complicated tickets.
  489. If you just want to get started already (and nobody would blame you!), try
  490. taking a look at the list of `easy tickets that need patches`__ and the
  491. `easy tickets that have patches which need improvement`__. If you're familiar
  492. with writing tests, you can also look at the list of
  493. `easy tickets that need tests`__. Just remember to follow the guidelines about
  494. claiming tickets that were mentioned in the link to Django's documentation on
  495. :doc:`claiming tickets and submitting patches
  496. </internals/contributing/writing-code/submitting-patches>`.
  497. __ 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
  498. __ 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
  499. __ 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
  500. What's next after creating a pull request?
  501. ------------------------------------------
  502. After a ticket has a patch, it needs to be reviewed by a second set of eyes.
  503. After submitting a pull request, update the ticket metadata by setting the
  504. flags on the ticket to say "has patch", "doesn't need tests", etc, so others
  505. can find it for review. Contributing doesn't necessarily always mean writing a
  506. patch from scratch. Reviewing existing patches is also a very helpful
  507. contribution. See :doc:`/internals/contributing/triaging-tickets` for details.