2011-05-27 18:49:47 +08:00
|
|
|
==================
|
|
|
|
Submitting patches
|
|
|
|
==================
|
|
|
|
|
|
|
|
We're always grateful for patches to Django's code. Indeed, bug reports
|
|
|
|
with associated patches will get fixed *far* more quickly than those
|
|
|
|
without patches.
|
|
|
|
|
2012-06-08 00:48:29 +08:00
|
|
|
Typo fixes and trivial documentation changes
|
|
|
|
--------------------------------------------
|
|
|
|
|
|
|
|
If you are fixing a really trivial issue, for example changing a word in the
|
|
|
|
documentation, the preferred way to provide the patch is using GitHub pull
|
|
|
|
requests without a Trac ticket. Trac tickets are still acceptable.
|
|
|
|
|
|
|
|
See the :doc:`working-with-git` for more details on how to use pull requests.
|
|
|
|
|
2011-05-27 18:49:47 +08:00
|
|
|
"Claiming" tickets
|
|
|
|
------------------
|
|
|
|
|
|
|
|
In an open-source project with hundreds of contributors around the world, it's
|
|
|
|
important to manage communication efficiently so that work doesn't get
|
2012-06-08 17:26:22 +08:00
|
|
|
duplicated and contributors can be as effective as possible.
|
|
|
|
|
|
|
|
Hence, our policy is for contributors to "claim" tickets in order to let other
|
|
|
|
developers know that a particular bug or feature is being worked on.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
|
|
|
If you have identified a contribution you want to make and you're capable of
|
|
|
|
fixing it (as measured by your coding ability, knowledge of Django internals
|
|
|
|
and time availability), claim it by following these steps:
|
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* `Create an account`_ to use in our ticket system. If you have an account
|
|
|
|
but have forgotten your password, you can reset it using the
|
|
|
|
`password reset page`_.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* If a ticket for this issue doesn't exist yet, create one in our
|
|
|
|
`ticket tracker`_.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* If a ticket for this issue already exists, make sure nobody else has
|
2013-06-08 13:53:27 +08:00
|
|
|
claimed it. To do this, look at the "Owned by" section of the ticket.
|
2011-10-14 08:12:01 +08:00
|
|
|
If it's assigned to "nobody," then it's available to be claimed.
|
|
|
|
Otherwise, somebody else is working on this ticket, and you either find
|
|
|
|
another bug/feature to work on, or contact the developer working on the
|
|
|
|
ticket to offer your help.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Log into your account, if you haven't already, by clicking "Login" in
|
|
|
|
the upper right of the ticket page.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Claim the ticket:
|
2011-08-26 17:44:40 +08:00
|
|
|
|
2013-06-08 13:53:27 +08:00
|
|
|
1. click the "assign to myself" radio button under "Action" near the bottom of the
|
2011-10-14 08:12:01 +08:00
|
|
|
page,
|
|
|
|
2. then click "Submit changes."
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2012-11-05 04:25:48 +08:00
|
|
|
.. note::
|
|
|
|
The Django software foundation requests that anyone contributing more than
|
|
|
|
a trivial patch to Django sign and submit a `Contributor License
|
|
|
|
Agreement`_, this ensures that the Django Software Foundation has clear
|
|
|
|
license to all contributions allowing for a clear license for all users.
|
|
|
|
|
2011-05-27 18:49:47 +08:00
|
|
|
.. _Create an account: https://www.djangoproject.com/accounts/register/
|
|
|
|
.. _password reset page: https://www.djangoproject.com/accounts/password/reset/
|
2012-11-05 04:25:48 +08:00
|
|
|
.. _Contributor License Agreement: https://www.djangoproject.com/foundation/cla/
|
2011-05-27 18:49:47 +08:00
|
|
|
|
|
|
|
Ticket claimers' responsibility
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Once you've claimed a ticket, you have a responsibility to work on that ticket
|
|
|
|
in a reasonably timely fashion. If you don't have time to work on it, either
|
|
|
|
unclaim it or don't claim it in the first place!
|
|
|
|
|
|
|
|
If there's no sign of progress on a particular claimed ticket for a week or
|
|
|
|
two, another developer may ask you to relinquish the ticket claim so that it's
|
|
|
|
no longer monopolized and somebody else can claim it.
|
|
|
|
|
|
|
|
If you've claimed a ticket and it's taking a long time (days or weeks) to code,
|
|
|
|
keep everybody updated by posting comments on the ticket. If you don't provide
|
|
|
|
regular updates, and you don't respond to a request for a progress report,
|
2012-06-08 17:26:22 +08:00
|
|
|
your claim on the ticket may be revoked.
|
|
|
|
|
|
|
|
As always, more communication is better than less communication!
|
2011-05-27 18:49:47 +08:00
|
|
|
|
|
|
|
Which tickets should be claimed?
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Of course, going through the steps of claiming tickets is overkill in some
|
2012-06-08 17:26:22 +08:00
|
|
|
cases.
|
|
|
|
|
|
|
|
In the case of small changes, such as typos in the documentation or
|
2011-05-27 18:49:47 +08:00
|
|
|
small bugs that will only take a few minutes to fix, you don't need to jump
|
|
|
|
through the hoops of claiming tickets. Just submit your patch and be done with
|
2012-06-08 17:26:22 +08:00
|
|
|
it.
|
|
|
|
|
|
|
|
Of course, it is *always* acceptable, regardless whether someone has claimed it
|
|
|
|
or not, to submit patches to a ticket if you happen to have a patch ready.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
|
|
|
.. _patch-style:
|
|
|
|
|
|
|
|
Patch style
|
|
|
|
-----------
|
|
|
|
|
2012-06-08 00:48:29 +08:00
|
|
|
Make sure that any contribution you do fulfills at least the following
|
|
|
|
requirements:
|
|
|
|
|
|
|
|
* The code required to fix a problem or add a feature is an essential part
|
2012-06-08 17:26:22 +08:00
|
|
|
of a patch, but it is not the only part. A good patch should also include a
|
|
|
|
:doc:`regression test <unit-tests>` to validate the behavior that has been
|
|
|
|
fixed and to prevent the problem from arising again. Also, if some tickets
|
|
|
|
are relevant to the code that you've written, mention the ticket numbers in
|
2012-06-08 00:48:29 +08:00
|
|
|
some comments in the test so that one can easily trace back the relevant
|
2012-06-08 17:26:22 +08:00
|
|
|
discussions after your patch gets committed, and the tickets get closed.
|
2012-06-08 00:48:29 +08:00
|
|
|
|
|
|
|
* If the code associated with a patch adds a new feature, or modifies
|
|
|
|
behavior of an existing feature, the patch should also contain
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
You can use either GitHub branches and pull requests or direct patches
|
|
|
|
to publish your work. If you use the Git workflow, then you should
|
|
|
|
announce your branch in the ticket by including a link to your branch.
|
|
|
|
When you think your work is ready to be merged in create a pull request.
|
2012-06-08 17:26:22 +08:00
|
|
|
|
2012-06-08 00:48:29 +08:00
|
|
|
See the :doc:`working-with-git` documentation for mode details.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2012-06-08 00:48:29 +08:00
|
|
|
You can also use patches in Trac. When using this style, follow these
|
|
|
|
guidelines.
|
|
|
|
|
|
|
|
* Submit patches in the format returned by the ``git diff`` command.
|
2011-10-14 08:12:01 +08:00
|
|
|
An exception is for code changes that are described more clearly in
|
|
|
|
plain English than in code. Indentation is the most common example; it's
|
|
|
|
hard to read patches when the only difference in code is that it's
|
|
|
|
indented.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Attach patches to a ticket in the `ticket tracker`_, using the "attach
|
|
|
|
file" button. Please *don't* put the patch in the ticket description
|
|
|
|
or comment unless it's a single line patch.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Name the patch file with a ``.diff`` extension; this will let the ticket
|
|
|
|
tracker apply correct syntax highlighting, which is quite helpful.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2012-06-08 00:48:29 +08:00
|
|
|
Regardless of the way you submit your work, follow these steps.
|
|
|
|
|
|
|
|
* Make sure your code matches our :doc:`coding-style`.
|
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Check the "Has patch" box on the ticket details. This will make it
|
|
|
|
obvious that the ticket includes a patch, and it will add the ticket to
|
|
|
|
the `list of tickets with patches`_.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
Non-trivial patches
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
A "non-trivial" patch is one that is more than a simple bug fix. It's a patch
|
|
|
|
that introduces Django functionality and makes some sort of design decision.
|
|
|
|
|
|
|
|
If you provide a non-trivial patch, include evidence that alternatives have
|
2013-10-04 06:51:22 +08:00
|
|
|
been discussed on |django-developers|.
|
2012-06-08 17:26:22 +08:00
|
|
|
|
|
|
|
If you're not sure whether your patch should be considered non-trivial, just
|
|
|
|
ask.
|
2011-05-27 18:49:47 +08:00
|
|
|
|
2014-06-03 04:07:28 +08:00
|
|
|
.. _deprecating-a-feature:
|
|
|
|
|
2013-09-18 01:23:32 +08:00
|
|
|
Deprecating a feature
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
There are a couple reasons that code in Django might be deprecated:
|
|
|
|
|
|
|
|
* If a feature has been improved or modified in a backwards-incompatible way,
|
|
|
|
the old feature or behavior will be deprecated.
|
|
|
|
|
|
|
|
* Sometimes Django will include a backport of a Python library that's not
|
|
|
|
included in a version of Python that Django currently supports. When Django
|
|
|
|
no longer needs to support the older version of Python that doesn't include
|
|
|
|
the library, the library will be deprecated in Django.
|
|
|
|
|
|
|
|
As the :ref:`deprecation policy<internal-release-deprecation-policy>` describes,
|
|
|
|
the first release of Django that deprecates a feature (``A.B``) should raise a
|
2014-02-27 05:48:20 +08:00
|
|
|
``RemovedInDjangoXXWarning`` (where XX is the Django version where the feature
|
|
|
|
will be removed) when the deprecated feature is invoked. Assuming
|
2013-09-18 01:23:32 +08:00
|
|
|
we have a good test coverage, these warnings will be shown by the test suite
|
|
|
|
when :ref:`running it <running-unit-tests>` with warnings enabled:
|
|
|
|
``python -Wall runtests.py``. This is annoying and the output of the test suite
|
2014-02-27 05:48:20 +08:00
|
|
|
should remain clean. Thus, when adding a ``RemovedInDjangoXXWarning`` you need
|
2013-09-18 01:23:32 +08:00
|
|
|
to eliminate or silence any warnings generated when running the tests.
|
|
|
|
|
|
|
|
The first step is to remove any use of the deprecated behavior by Django itself.
|
|
|
|
Next you can silence warnings in tests that actually test the deprecated
|
|
|
|
behavior in one of two ways:
|
|
|
|
|
|
|
|
#) In a particular test::
|
|
|
|
|
|
|
|
import warnings
|
|
|
|
|
|
|
|
def test_foo(self):
|
|
|
|
with warnings.catch_warnings(record=True) as w:
|
|
|
|
warnings.simplefilter("always")
|
|
|
|
# invoke deprecated behavior
|
|
|
|
# go ahead with the rest of the test
|
|
|
|
|
|
|
|
#) For an entire test case, ``django.test.utils`` contains three helpful
|
|
|
|
mixins to silence warnings: ``IgnorePendingDeprecationWarningsMixin``,
|
|
|
|
``IgnoreDeprecationWarningsMixin``, and
|
|
|
|
``IgnoreAllDeprecationWarningsMixin``. For example::
|
|
|
|
|
|
|
|
from django.test.utils import IgnorePendingDeprecationWarningsMixin
|
|
|
|
|
|
|
|
class MyDeprecatedTests(IgnorePendingDeprecationWarningsMixin, unittest.TestCase):
|
|
|
|
...
|
|
|
|
|
|
|
|
Finally, there are a couple of updates to Django's documentation to make:
|
|
|
|
|
|
|
|
#) If the existing feature is documented, mark it deprecated in documentation
|
|
|
|
using the ``.. deprecated:: A.B`` annotation. Include a short description
|
|
|
|
and a note about the upgrade path if applicable.
|
|
|
|
|
|
|
|
#) Add a description of the deprecated behavior, and the upgrade path if
|
|
|
|
applicable, to the current release notes (``docs/releases/A.B.txt``) under
|
|
|
|
the "Features deprecated in A.B" heading.
|
|
|
|
|
|
|
|
#) Add an entry in the deprecation timeline (``docs/internals/deprecation.txt``)
|
|
|
|
under the ``A.B+2`` version describing what code will be removed.
|
|
|
|
|
|
|
|
Once you have completed these steps, you are finished with the deprecation.
|
2014-02-27 05:48:20 +08:00
|
|
|
In each minor release, all ``RemovedInDjangoXXWarning``\s matching the new
|
|
|
|
version are removed.
|
2013-09-18 01:23:32 +08:00
|
|
|
|
2011-05-27 18:49:47 +08:00
|
|
|
Javascript patches
|
|
|
|
------------------
|
|
|
|
|
|
|
|
Django's admin system leverages the jQuery framework to increase the
|
|
|
|
capabilities of the admin interface. In conjunction, there is an emphasis on
|
|
|
|
admin javascript performance and minimizing overall admin media file size.
|
|
|
|
Serving compressed or "minified" versions of javascript files is considered
|
|
|
|
best practice in this regard.
|
|
|
|
|
|
|
|
To that end, patches for javascript files should include both the original
|
2011-07-19 21:16:09 +08:00
|
|
|
code for future development (e.g. ``foo.js``), and a compressed version for
|
|
|
|
production use (e.g. ``foo.min.js``). Any links to the file in the codebase
|
2011-05-27 18:49:47 +08:00
|
|
|
should point to the compressed version.
|
|
|
|
|
2012-06-08 17:26:22 +08:00
|
|
|
Compressing JavaScript
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
2011-05-27 18:49:47 +08:00
|
|
|
To simplify the process of providing optimized javascript code, Django
|
2013-02-03 05:53:43 +08:00
|
|
|
includes a handy python script which should be used to create a "minified"
|
|
|
|
version. To run it::
|
|
|
|
|
|
|
|
python django/contrib/admin/bin/compress.py
|
2011-05-27 18:49:47 +08:00
|
|
|
|
|
|
|
Behind the scenes, ``compress.py`` is a front-end for Google's
|
|
|
|
`Closure Compiler`_ which is written in Java. However, the Closure Compiler
|
|
|
|
library is not bundled with Django directly, so those wishing to contribute
|
|
|
|
complete javascript patches will need to download and install the library
|
|
|
|
independently.
|
|
|
|
|
|
|
|
The Closure Compiler library requires Java version 6 or higher (Java 1.6 or
|
2012-06-08 17:26:22 +08:00
|
|
|
higher on Mac OS X. Note that Mac OS X 10.5 and earlier did not ship with
|
2011-05-27 18:49:47 +08:00
|
|
|
Java 1.6 by default, so it may be necessary to upgrade your Java installation
|
|
|
|
before the tool will be functional. Also note that even after upgrading Java,
|
2011-07-19 21:16:09 +08:00
|
|
|
the default ``/usr/bin/java`` command may remain linked to the previous Java
|
2012-06-08 17:26:22 +08:00
|
|
|
binary, so relinking that command may be necessary as well.)
|
2011-05-27 18:49:47 +08:00
|
|
|
|
|
|
|
Please don't forget to run ``compress.py`` and include the ``diff`` of the
|
|
|
|
minified scripts when submitting patches for Django's javascript.
|
|
|
|
|
2012-03-14 15:41:02 +08:00
|
|
|
.. _Closure Compiler: https://developers.google.com/closure/compiler/
|
2012-03-14 01:53:31 +08:00
|
|
|
.. _list of tickets with patches: https://code.djangoproject.com/query?status=new&status=assigned&status=reopened&has_patch=1&order=priority
|
|
|
|
.. _ticket tracker: https://code.djangoproject.com/newticket
|
2014-06-03 04:07:28 +08:00
|
|
|
|
|
|
|
Patch review checklist
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
Use this checklist to review a pull request. If you are reviewing a pull
|
|
|
|
request that is not your own and it passes all the criteria below, please set
|
|
|
|
the "Triage Stage" on the corresponding Trac ticket to "Ready for checkin".
|
|
|
|
If you've left comments for improvement on the pull request, please tick the
|
|
|
|
appropriate flags on the Trac ticket based on the results of your review:
|
|
|
|
"Patch needs improvement", "Needs documentation", and/or "Needs tests". As time
|
|
|
|
and interest permits, core developers do final reviews of "Ready for checkin"
|
|
|
|
tickets and will either commit the patch or bump it back to "Accepted" if
|
|
|
|
further works need to be done. If you're looking to become a core developer,
|
|
|
|
doing thorough reviews of patches is a great way to earn trust.
|
|
|
|
|
|
|
|
Looking for a patch to review? Check out the "Patches needing review" section
|
|
|
|
of the `Django Development Dashboard <https://dashboard.djangoproject.com/>`_.
|
|
|
|
Looking to get your patch reviewed? Ensure the Trac flags on the ticket are
|
|
|
|
set so that the ticket appears in that queue.
|
|
|
|
|
|
|
|
Documentation
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
* Does the documentation build without any errors (``make html``, or
|
|
|
|
``make.bat html`` on Windows, from the ``docs`` directory)?
|
|
|
|
* Does the documentation follow the writing style guidelines in
|
|
|
|
:doc:`/internals/contributing/writing-documentation`?
|
|
|
|
* Are there any :ref:`spelling errors <documentation-spelling-check>`?
|
|
|
|
|
|
|
|
Bugs
|
|
|
|
~~~~
|
|
|
|
|
|
|
|
* Is there a proper regression test (the test should fail before the fix
|
|
|
|
is applied)?
|
|
|
|
|
|
|
|
New Features
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
|
|
* Are there tests to "exercise" all of the new code?
|
|
|
|
* Is there a release note in ``docs/releases/A.B.txt``?
|
|
|
|
* Is there documentation for the feature and is it annotated appropriately with
|
|
|
|
``.. versionadded:: A.B`` or ``.. versionchanged:: A.B``?
|
|
|
|
|
|
|
|
Deprecating a feature
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
See the :ref:`deprecating-a-feature` guide.
|
|
|
|
|
|
|
|
All code changes
|
|
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
* Does the :doc:`coding style
|
|
|
|
</internals/contributing/writing-code/coding-style>` conform to our
|
|
|
|
guidelines? Are there any ``flake8`` errors?
|
|
|
|
* If the change is backwards incompatible in any way, is there a note
|
|
|
|
in the release notes (``docs/releases/A.B.txt``)?
|
|
|
|
* Is Django's test suite passing? Ask in ``#django-developers`` for a core dev
|
|
|
|
to build the pull request against our continuous integration server.
|
|
|
|
|
|
|
|
All tickets
|
|
|
|
~~~~~~~~~~~
|
|
|
|
|
|
|
|
* Is the pull request a single squashed commit with a message that follows our
|
|
|
|
:ref:`commit message format <committing-guidelines>`?
|
|
|
|
* Are you the patch author and a new contributor? Please add yourself to the
|
|
|
|
``AUTHORS`` file and submit a `Contributor License Agreement`_.
|
|
|
|
|
|
|
|
.. _Contributor License Agreement: https://www.djangoproject.com/foundation/cla/
|