Django

Code

root/django/branches/0.95-bugfixes/docs/contributing.txt

Revision 3455, 19.0 kB (checked in by adrian, 2 years ago)

Added 'Please do not put your name in the code' section to docs/contributing.txt. Thanks to OSCON presentation for the inspiration

Line 
1 ======================
2 Contributing to Django
3 ======================
4
5 If you think working *with* Django is fun, wait until you start working *on* it.
6 We're passionate about helping Django users make the jump to contributing members
7 of the community, so there are many ways you can help Django's development:
8
9     * Blog about Django.  We syndicate all the Django blogs we know about on
10       the `community page`_; contact jacob@jacobian.org if you've got a blog
11       you'd like to see on that page.
12
13     * Report bugs and request features in our `ticket tracker`_.  Please read
14       `Reporting bugs`_, below, for the details on how we like our bug reports
15       served up.
16
17     * Submit patches for new and/or fixed behavior.  Please read `Submitting
18       patches`_, below, for details on how to submit a patch.
19
20     * Join the `django-developers`_ mailing list and share your ideas for how
21       to improve Django.  We're always open to suggestions, although we're
22       likely to be skeptical of large-scale suggestions without some code to
23       back it up.
24
25 That's all you need to know if you'd like to join the Django development
26 community. The rest of this document describes the details of how our community
27 works and how it handles bugs, mailing lists, and all the other minutiae of
28 Django development.
29
30 Reporting bugs
31 ==============
32
33 Well-written bug reports are *incredibly* helpful. However, there's a certain
34 amount of overhead involved in working with any bug tracking system, so your
35 help in keeping our ticket tracker as useful as possible is appreciated.  In
36 particular:
37
38     * **Do** read the FAQ_ to see if your issue might be a well-known question.
39
40     * **Do** `search the tracker`_ to see if your issue has already been filed.
41
42     * **Do** ask on `django-users`_ *first* if you're not sure if what you're
43       seeing is a bug.
44
45     * **Do** write complete, reproducible, specific bug reports. Include as
46       much information as you possibly can, complete with code snippets, test
47       cases, etc.  A minimal example that illustrates the bug in a nice small
48       test case is the best possible bug report.
49
50     * **Don't** use the ticket system to ask support questions.  Use the
51       `django-users`_ list, or the `#django`_ IRC channel for that.
52
53     * **Don't** use the ticket system to make large-scale feature requests.
54       We like to discuss any big changes to Django's core on the `django-developers`_
55       list before actually working on them.
56
57     * **Don't** reopen issues that have been marked "wontfix". This mark means
58       that the decision has been made that we can't or won't fix this particular
59       issue.  If you're not sure why, please ask on `django-developers`_.
60
61     * **Don't** use the ticket tracker for lengthy discussions, because they're
62       likely to get lost. If a particular ticket is controversial, please move
63       discussion to `django-developers`_.
64
65 Reporting security issues
66 =========================
67
68 Report security issues to security@djangoproject.com. This is a private list
69 only open to long-time, highly trusted Django developers, and its archives are
70 not publicly readable.
71
72 In the event of a confirmed vulnerability in Django itself, we will take the
73 following actions:
74
75     * Acknowledge to the reporter that we've received the report and that a fix
76       is forthcoming. We'll give a rough timeline and ask the reporter to keep
77       the issue confidential until we announce it.
78
79     * Halt all other development as long as is needed to develop a fix, including
80       patches against the current and two previous releases.
81
82     * Determine a go-public date for announcing the vulnerability and the fix.
83       To try to mitigate a possible "arms race" between those applying the patch
84       and those trying to exploit the hole, we will not announce security
85       problems immediately.
86
87     * Pre-notify everyone we know to be running the affected version(s) of
88       Django. We will send these notifications through private e-mail which will
89       include documentation of the vulnerability, links to the relevant patch(es),
90       and a request to keep the vulnerability confidential until the official
91       go-public date.
92
93     * Publicly announce the vulnerability and the fix on the pre-determined
94       go-public date. This will probably mean a new release of Django, but
95       in some cases it may simply be patches against current releases.
96
97 Submitting patches
98 ==================
99
100 We're always grateful for patches to Django's code. Indeed, bug reports with
101 associated patches will get fixed *far* more quickly than those without patches.
102
103 Patch style
104 -----------
105
106     * Make sure your code matches our `coding style`_.
107
108     * Submit patches in the format returned by the ``svn diff`` command.
109       An exception is for code changes that are described more clearly in plain
110       English than in code. Indentation is the most common example; it's hard to
111       read patches when the only difference in code is that it's indented.
112
113     * Attach patches to a ticket in the `ticket tracker`_, using the "attach file"
114       button. Please *don't* put the patch in the ticket description or comment
115       unless it's a single line patch.
116
117     * Name the patch file with a ``.diff`` extension; this will let the ticket
118       tracker apply correct syntax highlighting, which is quite helpful.
119
120     * Put the prefix "[patch] " before the title of your ticket. This will make
121       it obvious that the ticket includes a patch, and it will add the ticket
122       to the `list of tickets with patches`_.
123
124 Submitting and maintaining translations
125 =======================================
126
127 Various parts of Django, such as the admin site and validator error messages,
128 are internationalized. This means they display different text depending on a
129 user's language setting.
130
131 These translations are contributed by Django users worldwide. If you find an
132 incorrect translation, or if you'd like to add a language that isn't yet
133 translated, here's what to do:
134
135     * Join the `Django i18n mailing list`_ and introduce yourself.
136     * Create and submit translations using the methods described in the
137       `i18n documentation`_.
138
139 .. _Django i18n mailing list: http://groups.google.com/group/django-i18n/
140 .. _i18n documentation: http://www.djangoproject.com/documentation/i18n/
141
142 Coding style
143 ============
144
145 Please follow these coding standards when writing code for inclusion in Django:
146
147     * Unless otherwise specified, follow `PEP 8`_.
148
149     * Use four spaces for indentation.
150
151     * Use underscores, not camelCase, for variable, function and method names
152       (i.e. ``poll.get_unique_voters()``, not ``poll.getUniqueVoters``).
153
154     * Use ``InitialCaps`` for class names (or for factory functions that
155       return classes).
156
157     * Mark all strings for internationalization; see the `i18n documentation`_
158       for details.
159
160     * In Django template code, put one (and only one) space between the curly
161       brackets and the tag contents.
162
163       Do this::
164
165           {{ foo }}
166
167       Don't do this::
168
169           {{foo}}
170
171     * Please don't put your name in the code. While we appreciate all
172       contributions to Django, our policy is not to publish individual
173       developer names in code -- for instance, at the top of Python modules.
174
175 Committing code
176 ===============
177
178 Please follow these guidelines when committing code to Django's Subversion
179 repository:
180
181     * For any medium-to-big changes, where "medium-to-big" is according to your
182       judgment, please bring things up on the `django-developers`_ mailing list
183       before making the change.
184
185       If you bring something up on `django-developers`_ and nobody responds,
186       please don't take that to mean your idea is great and should be
187       implemented immediately because nobody contested it. Django's lead
188       developers don't have a lot of time to read mailing-list discussions
189       immediately, so you may have to wait a couple of days before getting a
190       response.
191
192     * Write detailed commit messages in the past tense, not present tense.
193
194           * Good: "Fixed Unicode bug in RSS API."
195           * Bad: "Fixes Unicode bug in RSS API."
196           * Bad: "Fixing Unicode bug in RSS API."
197
198     * For commits to a branch, prefix the commit message with the branch name.
199       For example: "magic-removal: Added support for mind reading."
200
201     * Limit commits to the most granular change that makes sense. This means,
202       use frequent small commits rather than infrequent large commits. For
203       example, if implementing feature X requires a small change to library Y,
204       first commit the change to library Y, then commit feature X in a separate
205       commit. This goes a *long way* in helping all core Django developers
206       follow your changes.
207
208     * If your commit closes a ticket in the Django `ticket tracker`_, begin
209       your commit message with the text "Fixed #abc", where "abc" is the number
210       of the ticket your commit fixes. Example: "Fixed #123 -- Added support
211       for foo". We've rigged Subversion and Trac so that any commit message
212       in that format will automatically close the referenced ticket and post a
213       comment to it with the full commit message.
214
215       If your commit closes a ticket and is in a branch, use the branch name
216       first, then the "Fixed #abc." For example:
217       "magic-removal: Fixed #123 -- Added whizbang feature."
218
219       For the curious: We're using a `Trac post-commit hook`_ for this.
220
221       .. _Trac post-commit hook: http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook
222
223     * If your commit references a ticket in the Django `ticket tracker`_ but
224       does *not* close the ticket, include the phrase "Refs #abc", where "abc"
225       is the number of the ticket your commit references. We've rigged
226       Subversion and Trac so that any commit message in that format will
227       automatically post a comment to the appropriate ticket.
228
229 Unit tests
230 ==========
231
232 Django comes with a test suite of its own, in the ``tests`` directory of the
233 Django tarball. It's our policy to make sure all tests pass at all times.
234
235 The tests cover:
236
237     * Models and the database API (``tests/testapp/models``).
238     * The cache system (``tests/otherthests/cache.py``).
239     * The ``django.utils.dateformat`` module (``tests/othertests/dateformat.py``).
240     * Database typecasts (``tests/othertests/db_typecasts.py``).
241     * The template system (``tests/othertests/templates.py`` and
242       ``tests/othertests/defaultfilters.py``).
243     * ``QueryDict`` objects (``tests/othertests/httpwrappers.py``).
244     * Markup template tags (``tests/othertests/markup.py``).
245     * The ``django.utils.timesince`` module (``tests/othertests/timesince.py``).
246
247 We appreciate any and all contributions to the test suite!
248
249 Running the unit tests
250 ----------------------
251
252 To run the tests, ``cd`` to the ``tests/`` directory and type::
253
254     ./runtests.py --settings=path.to.django.settings
255
256 Yes, the unit tests need a settings module, but only for database connection
257 info -- the ``DATABASE_ENGINE``, ``DATABASE_USER`` and ``DATABASE_PASSWORD``.
258
259 The unit tests will not touch your database; they create a new database, called
260 ``django_test_db``, which is deleted when the tests are finished. This means
261 your user account needs permission to execute ``CREATE DATABASE``.
262
263 Requesting features
264 ===================
265
266 We're always trying to make Django better, and your feature requests are a key
267 part of that. Here are some tips on how to most effectively make a request:
268
269     * Request the feature on `django-developers`_, not in the ticket tracker;
270       it'll get read more closely if it's on the mailing list.
271
272     * Describe clearly and concisely what the missing feature is and how you'd
273       like to see it implemented. Include example code (non-functional is OK)
274       if possible.
275
276     * Explain *why* you'd like the feature. In some cases this is obvious, but
277       since Django is designed to help real developers get real work done,
278       you'll need to explain it, if it isn't obvious why the feature would be
279       useful.
280
281 As with most open-source projects, code talks. If you are willing to write the
282 code for the feature yourself or if (even better) you've already written it,
283 it's much more likely to be accepted.  If it's a large feature that might need
284 multiple developers we're always happy to give you an experimental branch in
285 our repository; see below.
286
287 Branch policy
288 =============
289
290 In general, most development is confined to the trunk, and the trunk
291 is kept stable. People should be able to run production sites against the
292 trunk at any time.
293
294 Thus, large architectural changes -- that is, changes too large to be
295 encapsulated in a single patch, or changes that need multiple eyes on them --
296 will have dedicated branches. See, for example, the `i18n branch`_. If you
297 have a change of this nature that you'd like to work on, ask on
298 `django-developers`_ for a branch to be created for you. We'll create a branch
299 for pretty much any kind of experimenting you'd like to do.
300
301 We will only branch entire copies of the Django tree, even if work is only
302 happening on part of that tree. This makes it painless to switch to a branch.
303
304 Developers working on a branch should periodically merge changes from the trunk
305 into the branch. Please merge at least once a week. Every time you merge from
306 the trunk, note the merge and revision numbers in the commit message.
307
308 Once the branch is stable and ready to be merged into the trunk, alert
309 `django-developers`_.
310
311 After a branch has been merged, it should be considered "dead"; write access to
312 it will be disabled, and old branches will be periodically "trimmed." To keep
313 our SVN wrangling to a minimum, we won't be merging from a given branch into the
314 trunk more than once.
315
316 Using branches
317 --------------
318
319 To test a given branch, you can simply check out the entire branch, like so::
320
321     svn co http://code.djangoproject.com/svn/django/branches/<branch>/
322
323 Or, if you've got a working directory you'd like to switch to use a branch,
324 you can use::
325
326     svn switch http://code.djangoproject.com/svn/django/branches/<branch>/
327
328 ...in the root of your Django sandbox (the directory that contains ``django``,
329 ``docs``, and ``tests``).
330
331 The advantage of using ``svn switch`` instead of ``svn co`` is that the
332 ``switch`` command retains any changes you might have made to your local copy
333 of the code. It attempts to merge those changes into the "switched" code.
334
335 Official releases
336 =================
337
338 Django's release numbering works as follows:
339
340     * Versions are numbered in the form ``A.B`` or ``A.B.C``.
341
342     * ``A`` is the major version number, which is only incremented for major
343       changes to Django, and these changes are not necessarily
344       backwards-compatible. That is, code you wrote for Django 6.0 may break
345       when we release Django 7.0.
346
347     * ``B`` is the minor version number, which is incremented for large yet
348       backwards compatible changes.  Code written for Django 6.4 will continue
349       to work under Django 6.5.
350
351       A minor release may deprecate certain features in previous releases. If a
352       feature in version ``A.B`` is deprecated, it will continue to work in
353       version ``A.B+1``. In version ``A.B+2``, use of the feature will raise a
354       ``PendingDeprecationWarning`` but will continue to work.  Version
355       ``A.B+3`` will remove the feature entirely. Major point releases will
356       always remove deprecated features immediately.
357
358     * ``C`` is the micro version number which, is incremented for bug and
359       security fixes.  A new micro-release will always be 100%
360       backwards-compatible with the previous micro-release.
361
362     * In some cases, we'll make release candidate releases. These are of the
363       form ``A.BrcN``, which means the ``Nth`` candidate release of version
364       ``A.B``.
365
366 An exception to this version numbering scheme is the pre-1.0 Django code.
367 There's no guarantee of backwards-compatibility until the 1.0 release.
368
369 In Subversion, each Django release will be tagged under `tags/releases`_.  If
370 it's necessary to release a bug fix release or a security release that doesn't
371 come from the trunk, we'll copy that tag to ``branches/releases`` to make the
372 bug fix release.
373
374 Deciding on features
375 ====================
376
377 Once a feature's been requested and discussed, eventually we'll have a decision
378 about whether to include the feature or drop it.
379
380 Whenever possible, we strive for a rough consensus. To that end, we'll often
381 have informal votes on `django-developers`_ about a feature. In these votes we
382 follow the voting style invented by Apache and used on Python itself, where
383 votes are given as +1, +0, -0, or -1.  Roughly translated, these votes mean:
384
385     * +1: "I love the idea and I'm strongly committed to it."
386
387     * +0: "Sounds OK to me."
388
389     * -0: "I'm not thrilled, but I won't stand in the way."
390
391     * -1: "I strongly disagree and would be very unhappy to see the idea turn
392       into reality."
393
394 Although these votes on django-developers are informal, they'll be taken very
395 seriously. After a suitable voting period, if an obvious consensus arises
396 we'll follow the votes.
397
398 However, consensus is not always possible.  Tough decisions will be discussed by
399 all full committers and finally decided by the Benevolent Dictators for Life,
400 Adrian and Jacob.
401
402 Commit access
403 =============
404
405 Django has two types of committers:
406
407 Full committers
408     These are people who have a long history of contributions to Django's
409     codebase, a solid track record of being polite and helpful on the mailing
410     lists, and a proven desire to dedicate serious time to Django's development.
411
412     The bar is very high for full commit access. It will only be granted by
413     unanimous approval of all existing full committers, and the decision will err
414     on the side of rejection.
415
416 Partial committers
417     These are people who are "domain experts." They have direct check-in access
418     to the subsystems that fall under their jurisdiction, and they're given a
419     formal vote in questions that involve their subsystems. This type of access
420     is likely to be given to someone who contributes a large subframework to
421     Django and wants to continue to maintain it.
422
423     Like full committers, partial commit access is by unanimous approval of all
424     full committers (and any other partial committers in the same area).
425     However, the bar is set lower; proven expertise in the area in question is
426     likely to be sufficient.
427
428 To request commit access, please contact an existing committer privately. Public
429 requests for commit access are potential flame-war starters, and will be ignored.
430
431 .. _community page: http://www.djangoproject.com/community/
432 .. _ticket tracker: http://code.djangoproject.com/newticket
433 .. _django-developers: http://groups.google.com/group/django-developers
434 .. _FAQ: http://www.djangoproject.com/documentation/faq/
435 .. _search the tracker: http://code.djangoproject.com/search
436 .. _django-users: http://groups.google.com/group/django-users
437 .. _`#django`: irc://irc.freenode.net/django
438 .. _list of tickets with patches: http://code.djangoproject.com/report/12
439 .. _PEP 8: http://www.python.org/peps/pep-0008.html
440 .. _i18n documentation: http://www.djangoproject.com/documentation/i18n/
441 .. _i18n branch: http://code.djangoproject.com/browser/django/branches/i18n
442 .. _`tags/releases`: http://code.djangoproject.com/browser/django/tags/releases
Note: See TracBrowser for help on using the browser.