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.
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.
See the Working with Git and GitHub for more details on how to use pull requests.
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 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.
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:
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.
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, your claim on the ticket may be revoked.
As always, more communication is better than less communication!
Of course, going through the steps of claiming tickets is overkill in some cases.
In the case of small changes, such as typos in the documentation or 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 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.
Make sure that any contribution you do fulfills at least the following requirements:
When you think your work is ready to be reviewed, send a GitHub pull request. Please review the patch yourself using our patch review checklist first.
If you can’t send a pull request for some reason, you can also use patches in Trac. When using this style, follow these guidelines.
git diff
command..diff
extension; this will let the ticket
tracker apply correct syntax highlighting, which is quite helpful.Regardless of the way you submit your work, follow these steps.
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 been discussed on django-developers.
If you’re not sure whether your patch should be considered non-trivial, just ask.
There are a couple reasons that code in Django might be deprecated:
As the deprecation policy describes,
the first release of Django that deprecates a feature (A.B
) should raise a
RemovedInDjangoXXWarning
(where XX is the Django version where the feature
will be removed) when the deprecated feature is invoked. Assuming we have good
test coverage, these warnings are converted to errors when running the
test suite with warnings enabled:
python -Wall runtests.py
. Thus, when adding a RemovedInDjangoXXWarning
you need 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 by using the ignore_warnings
decorator, either at the test or class
level:
In a particular test:
from django.test import ignore_warnings
from django.utils.deprecation import RemovedInDjangoXXWarning
@ignore_warnings(category=RemovedInDjangoXXWarning)
def test_foo(self):
...
For an entire test case:
from django.test import ignore_warnings
from django.utils.deprecation import RemovedInDjangoXXWarning
@ignore_warnings(category=RemovedInDjangoXXWarning)
class MyDeprecatedTests(unittest.TestCase):
...
You can also add a test for the deprecation warning. You’ll have to disable the “warning as error” behavior in your test by doing:
import warnings
def test_foo_deprecation_warning(self):
with warnings.catch_warnings(record=True) as warns:
warnings.simplefilter('always') # prevent warnings from appearing as errors
# invoke deprecated behavior
self.assertEqual(len(warns), 1)
msg = str(warns[0].message)
self.assertEqual(msg, 'Expected deprecation message')
Finally, there are a couple of updates to Django’s documentation to make:
.. deprecated:: A.B
annotation. Include a short description
and a note about the upgrade path if applicable.docs/releases/A.B.txt
) under
the “Features deprecated in A.B” heading.docs/internals/deprecation.txt
)
under the appropriate version describing what code will be removed.Once you have completed these steps, you are finished with the deprecation.
In each feature release, all RemovedInDjangoXXWarning
s matching
the new version are removed.
For information on JavaScript patches, see the JavaScript patches documentation.
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, committers 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 committer, 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. Looking to get your patch reviewed? Ensure the Trac flags on the ticket are set so that the ticket appears in that queue.
make html
, or
make.bat html
on Windows, from the docs
directory)?docs/releases/A.B.txt
?.. versionadded:: A.B
or .. versionchanged:: A.B
?See the Deprecating a feature guide.
flake8
errors?docs/releases/A.B.txt
)?AUTHORS
file and submit a Contributor License Agreement.Jun 22, 2017