Django

Code

root/django/branches/schema-evolution-ng/docs/contributing.txt

Revision 4203, 23.8 kB (checked in by adrian, 2 years ago)

Beefed up 'Using branches' part of docs/contributing.txt

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