| 1 |
.. _internals-contributing: |
|---|
| 2 |
|
|---|
| 3 |
====================== |
|---|
| 4 |
Contributing to Django |
|---|
| 5 |
====================== |
|---|
| 6 |
|
|---|
| 7 |
If you think working *with* Django is fun, wait until you start working *on* it. |
|---|
| 8 |
We're passionate about helping Django users make the jump to contributing members |
|---|
| 9 |
of the community, so there are many ways you can help Django's development: |
|---|
| 10 |
|
|---|
| 11 |
* Blog about Django. We syndicate all the Django blogs we know about on |
|---|
| 12 |
the `community page`_; contact jacob@jacobian.org if you've got a blog |
|---|
| 13 |
you'd like to see on that page. |
|---|
| 14 |
|
|---|
| 15 |
* Report bugs and request features in our `ticket tracker`_. Please read |
|---|
| 16 |
`Reporting bugs`_, below, for the details on how we like our bug reports |
|---|
| 17 |
served up. |
|---|
| 18 |
|
|---|
| 19 |
* Submit patches for new and/or fixed behavior. Please read `Submitting |
|---|
| 20 |
patches`_, below, for details on how to submit a patch. |
|---|
| 21 |
|
|---|
| 22 |
* Join the `django-developers`_ mailing list and share your ideas for how |
|---|
| 23 |
to improve Django. We're always open to suggestions, although we're |
|---|
| 24 |
likely to be skeptical of large-scale suggestions without some code to |
|---|
| 25 |
back it up. |
|---|
| 26 |
|
|---|
| 27 |
* Triage patches that have been submitted by other users. Please read |
|---|
| 28 |
`Ticket triage`_ below, for details on the triage process. |
|---|
| 29 |
|
|---|
| 30 |
That's all you need to know if you'd like to join the Django development |
|---|
| 31 |
community. The rest of this document describes the details of how our community |
|---|
| 32 |
works and how it handles bugs, mailing lists, and all the other minutiae of |
|---|
| 33 |
Django development. |
|---|
| 34 |
|
|---|
| 35 |
.. _reporting-bugs: |
|---|
| 36 |
|
|---|
| 37 |
Reporting bugs |
|---|
| 38 |
============== |
|---|
| 39 |
|
|---|
| 40 |
Well-written bug reports are *incredibly* helpful. However, there's a certain |
|---|
| 41 |
amount of overhead involved in working with any bug tracking system, so your |
|---|
| 42 |
help in keeping our ticket tracker as useful as possible is appreciated. In |
|---|
| 43 |
particular: |
|---|
| 44 |
|
|---|
| 45 |
* **Do** read the :ref:`FAQ <faq-index>` to see if your issue might be a well-known question. |
|---|
| 46 |
|
|---|
| 47 |
* **Do** `search the tracker`_ to see if your issue has already been filed. |
|---|
| 48 |
|
|---|
| 49 |
* **Do** ask on `django-users`_ *first* if you're not sure if what you're |
|---|
| 50 |
seeing is a bug. |
|---|
| 51 |
|
|---|
| 52 |
* **Do** write complete, reproducible, specific bug reports. Include as |
|---|
| 53 |
much information as you possibly can, complete with code snippets, test |
|---|
| 54 |
cases, etc. This means including a clear, concise description of the |
|---|
| 55 |
problem, and a clear set of instructions for replicating the problem. |
|---|
| 56 |
A minimal example that illustrates the bug in a nice small test case |
|---|
| 57 |
is the best possible bug report. |
|---|
| 58 |
|
|---|
| 59 |
* **Don't** use the ticket system to ask support questions. Use the |
|---|
| 60 |
`django-users`_ list, or the `#django`_ IRC channel for that. |
|---|
| 61 |
|
|---|
| 62 |
* **Don't** use the ticket system to make large-scale feature requests. |
|---|
| 63 |
We like to discuss any big changes to Django's core on the `django-developers`_ |
|---|
| 64 |
list before actually working on them. |
|---|
| 65 |
|
|---|
| 66 |
* **Don't** reopen issues that have been marked "wontfix". This mark means |
|---|
| 67 |
that the decision has been made that we can't or won't fix this particular |
|---|
| 68 |
issue. If you're not sure why, please ask on `django-developers`_. |
|---|
| 69 |
|
|---|
| 70 |
* **Don't** use the ticket tracker for lengthy discussions, because they're |
|---|
| 71 |
likely to get lost. If a particular ticket is controversial, please move |
|---|
| 72 |
discussion to `django-developers`_. |
|---|
| 73 |
|
|---|
| 74 |
* **Don't** post to django-developers just to announce that you have filed |
|---|
| 75 |
a bug report. All the tickets are mailed to another list |
|---|
| 76 |
(`django-updates`_), which is tracked by developers and triagers, so we |
|---|
| 77 |
see them as they are filed. |
|---|
| 78 |
|
|---|
| 79 |
.. _django-updates: http://groups.google.com/group/django-updates |
|---|
| 80 |
|
|---|
| 81 |
.. _reporting-security-issues: |
|---|
| 82 |
|
|---|
| 83 |
Reporting security issues |
|---|
| 84 |
========================= |
|---|
| 85 |
|
|---|
| 86 |
Report security issues to security@djangoproject.com. This is a private list |
|---|
| 87 |
only open to long-time, highly trusted Django developers, and its archives are |
|---|
| 88 |
not publicly readable. |
|---|
| 89 |
|
|---|
| 90 |
In the event of a confirmed vulnerability in Django itself, we will take the |
|---|
| 91 |
following actions: |
|---|
| 92 |
|
|---|
| 93 |
* Acknowledge to the reporter that we've received the report and that a fix |
|---|
| 94 |
is forthcoming. We'll give a rough timeline and ask the reporter to keep |
|---|
| 95 |
the issue confidential until we announce it. |
|---|
| 96 |
|
|---|
| 97 |
* Halt all other development as long as is needed to develop a fix, including |
|---|
| 98 |
patches against the current and two previous releases. |
|---|
| 99 |
|
|---|
| 100 |
* Determine a go-public date for announcing the vulnerability and the fix. |
|---|
| 101 |
To try to mitigate a possible "arms race" between those applying the patch |
|---|
| 102 |
and those trying to exploit the hole, we will not announce security |
|---|
| 103 |
problems immediately. |
|---|
| 104 |
|
|---|
| 105 |
* Pre-notify everyone we know to be running the affected version(s) of |
|---|
| 106 |
Django. We will send these notifications through private e-mail which will |
|---|
| 107 |
include documentation of the vulnerability, links to the relevant patch(es), |
|---|
| 108 |
and a request to keep the vulnerability confidential until the official |
|---|
| 109 |
go-public date. |
|---|
| 110 |
|
|---|
| 111 |
* Publicly announce the vulnerability and the fix on the pre-determined |
|---|
| 112 |
go-public date. This will probably mean a new release of Django, but |
|---|
| 113 |
in some cases it may simply be patches against current releases. |
|---|
| 114 |
|
|---|
| 115 |
Submitting patches |
|---|
| 116 |
================== |
|---|
| 117 |
|
|---|
| 118 |
We're always grateful for patches to Django's code. Indeed, bug reports with |
|---|
| 119 |
associated patches will get fixed *far* more quickly than those without patches. |
|---|
| 120 |
|
|---|
| 121 |
"Claiming" tickets |
|---|
| 122 |
------------------ |
|---|
| 123 |
|
|---|
| 124 |
In an open-source project with hundreds of contributors around the world, it's |
|---|
| 125 |
important to manage communication efficiently so that work doesn't get |
|---|
| 126 |
duplicated and contributors can be as effective as possible. Hence, our policy |
|---|
| 127 |
is for contributors to "claim" tickets in order to let other developers know |
|---|
| 128 |
that a particular bug or feature is being worked on. |
|---|
| 129 |
|
|---|
| 130 |
If you have identified a contribution you want to make and you're capable of |
|---|
| 131 |
fixing it (as measured by your coding ability, knowledge of Django internals |
|---|
| 132 |
and time availability), claim it by following these steps: |
|---|
| 133 |
|
|---|
| 134 |
* `Create an account`_ to use in our ticket system. |
|---|
| 135 |
* If a ticket for this issue doesn't exist yet, create one in our |
|---|
| 136 |
`ticket tracker`_. |
|---|
| 137 |
* If a ticket for this issue already exists, make sure nobody else has |
|---|
| 138 |
claimed it. To do this, look at the "Assigned to" section of the ticket. |
|---|
| 139 |
If it's assigned to "nobody," then it's available to be claimed. |
|---|
| 140 |
Otherwise, somebody else is working on this ticket, and you either find |
|---|
| 141 |
another bug/feature to work on, or contact the developer working on the |
|---|
| 142 |
ticket to offer your help. |
|---|
| 143 |
* Log into your account, if you haven't already, by clicking "Login" in the |
|---|
| 144 |
upper right of the ticket page. |
|---|
| 145 |
* Claim the ticket by clicking the radio button next to "Accept ticket" |
|---|
| 146 |
near the bottom of the page, then clicking "Submit changes." |
|---|
| 147 |
|
|---|
| 148 |
.. _Create an account: http://www.djangoproject.com/accounts/register/ |
|---|
| 149 |
|
|---|
| 150 |
Ticket claimers' responsibility |
|---|
| 151 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 152 |
|
|---|
| 153 |
Once you've claimed a ticket, you have a responsibility to work on that ticket |
|---|
| 154 |
in a reasonably timely fashion. If you don't have time to work on it, either |
|---|
| 155 |
unclaim it or don't claim it in the first place! |
|---|
| 156 |
|
|---|
| 157 |
Ticket triagers go through the list of claimed tickets from time to |
|---|
| 158 |
time, checking whether any progress has been made. If there's no sign of |
|---|
| 159 |
progress on a particular claimed ticket for a week or two, a triager may ask |
|---|
| 160 |
you to relinquish the ticket claim so that it's no longer monopolized and |
|---|
| 161 |
somebody else can claim it. |
|---|
| 162 |
|
|---|
| 163 |
If you've claimed a ticket and it's taking a long time (days or weeks) to code, |
|---|
| 164 |
keep everybody updated by posting comments on the ticket. If you don't provide |
|---|
| 165 |
regular updates, and you don't respond to a request for a progress report, |
|---|
| 166 |
your claim on the ticket may be revoked. As always, more communication is |
|---|
| 167 |
better than less communication! |
|---|
| 168 |
|
|---|
| 169 |
Which tickets should be claimed? |
|---|
| 170 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 171 |
|
|---|
| 172 |
Of course, going through the steps of claiming tickets is overkill in some |
|---|
| 173 |
cases. In the case of small changes, such as typos in the documentation or |
|---|
| 174 |
small bugs that will only take a few minutes to fix, you don't need to jump |
|---|
| 175 |
through the hoops of claiming tickets. Just submit your patch and be done with |
|---|
| 176 |
it. |
|---|
| 177 |
|
|---|
| 178 |
Patch style |
|---|
| 179 |
----------- |
|---|
| 180 |
|
|---|
| 181 |
* Make sure your code matches our `coding style`_. |
|---|
| 182 |
|
|---|
| 183 |
* Submit patches in the format returned by the ``svn diff`` command. |
|---|
| 184 |
An exception is for code changes that are described more clearly in plain |
|---|
| 185 |
English than in code. Indentation is the most common example; it's hard to |
|---|
| 186 |
read patches when the only difference in code is that it's indented. |
|---|
| 187 |
|
|---|
| 188 |
Patches in ``git diff`` format are also acceptable. |
|---|
| 189 |
|
|---|
| 190 |
* When creating patches, always run ``svn diff`` from the top-level |
|---|
| 191 |
``trunk`` directory -- i.e., the one that contains ``django``, ``docs``, |
|---|
| 192 |
``tests``, ``AUTHORS``, etc. This makes it easy for other people to apply |
|---|
| 193 |
your patches. |
|---|
| 194 |
|
|---|
| 195 |
* Attach patches to a ticket in the `ticket tracker`_, using the "attach file" |
|---|
| 196 |
button. Please *don't* put the patch in the ticket description or comment |
|---|
| 197 |
unless it's a single line patch. |
|---|
| 198 |
|
|---|
| 199 |
* Name the patch file with a ``.diff`` extension; this will let the ticket |
|---|
| 200 |
tracker apply correct syntax highlighting, which is quite helpful. |
|---|
| 201 |
|
|---|
| 202 |
* Check the "Has patch" box on the ticket details. This will make it |
|---|
| 203 |
obvious that the ticket includes a patch, and it will add the ticket to |
|---|
| 204 |
the `list of tickets with patches`_. |
|---|
| 205 |
|
|---|
| 206 |
* The code required to fix a problem or add a feature is an essential part |
|---|
| 207 |
of a patch, but it is not the only part. A good patch should also include |
|---|
| 208 |
a regression test to validate the behavior that has been fixed (and prevent |
|---|
| 209 |
the problem from arising again). |
|---|
| 210 |
|
|---|
| 211 |
* If the code associated with a patch adds a new feature, or modifies behavior |
|---|
| 212 |
of an existing feature, the patch should also contain documentation. |
|---|
| 213 |
|
|---|
| 214 |
Non-trivial patches |
|---|
| 215 |
------------------- |
|---|
| 216 |
|
|---|
| 217 |
A "non-trivial" patch is one that is more than a simple bug fix. It's a patch |
|---|
| 218 |
that introduces Django functionality and makes some sort of design decision. |
|---|
| 219 |
|
|---|
| 220 |
If you provide a non-trivial patch, include evidence that alternatives have |
|---|
| 221 |
been discussed on `django-developers`_. If you're not sure whether your patch |
|---|
| 222 |
should be considered non-trivial, just ask. |
|---|
| 223 |
|
|---|
| 224 |
Ticket triage |
|---|
| 225 |
============= |
|---|
| 226 |
|
|---|
| 227 |
Unfortunately, not all bug reports in the `ticket tracker`_ provide all |
|---|
| 228 |
the `required details`_. A number of tickets have patches, but those patches |
|---|
| 229 |
don't meet all the requirements of a `good patch`_. |
|---|
| 230 |
|
|---|
| 231 |
One way to help out is to *triage* bugs that have been reported by other |
|---|
| 232 |
users. A couple of dedicated volunteers work on this regularly, but more help |
|---|
| 233 |
is always appreciated. |
|---|
| 234 |
|
|---|
| 235 |
Most of the workflow is based around the concept of a ticket's "triage stage". |
|---|
| 236 |
This stage describes where in its lifetime a given ticket is at any time. |
|---|
| 237 |
Along with a handful of flags, this field easily tells us what and who each |
|---|
| 238 |
ticket is waiting on. |
|---|
| 239 |
|
|---|
| 240 |
Since a picture is worth a thousand words, let's start there: |
|---|
| 241 |
|
|---|
| 242 |
.. image:: _images/djangotickets.png |
|---|
| 243 |
:height: 451 |
|---|
| 244 |
:width: 590 |
|---|
| 245 |
:alt: Django's ticket workflow |
|---|
| 246 |
|
|---|
| 247 |
We've got two official roles here: |
|---|
| 248 |
|
|---|
| 249 |
* Core developers: people with commit access who make the big decisions |
|---|
| 250 |
and write the bulk of the code. |
|---|
| 251 |
|
|---|
| 252 |
* Ticket triagers: trusted community members with a proven history of |
|---|
| 253 |
working with the Django community. As a result of this history, they |
|---|
| 254 |
have been entrusted by the core developers to make some of the smaller |
|---|
| 255 |
decisions about tickets. |
|---|
| 256 |
|
|---|
| 257 |
Second, note the five triage stages: |
|---|
| 258 |
|
|---|
| 259 |
1. A ticket starts as "Unreviewed", meaning that nobody has examined |
|---|
| 260 |
the ticket. |
|---|
| 261 |
|
|---|
| 262 |
2. "Design decision needed" means "this concept requires a design |
|---|
| 263 |
decision," which should be discussed either in the ticket comments or on |
|---|
| 264 |
`django-developers`_. The "Design decision needed" step will generally |
|---|
| 265 |
only be used for feature requests. It can also be used for issues |
|---|
| 266 |
that *might* be bugs, depending on opinion or interpretation. Obvious |
|---|
| 267 |
bugs (such as crashes, incorrect query results, or non-compliance with a |
|---|
| 268 |
standard) skip this step and move straight to "Accepted". |
|---|
| 269 |
|
|---|
| 270 |
3. Once a ticket is ruled to be approved for fixing, it's moved into the |
|---|
| 271 |
"Accepted" stage. This stage is where all the real work gets done. |
|---|
| 272 |
|
|---|
| 273 |
4. In some cases, a ticket might get moved to the "Someday/Maybe" state. |
|---|
| 274 |
This means the ticket is an enhancement request that we might consider |
|---|
| 275 |
adding to the framework if an excellent patch is submitted. These |
|---|
| 276 |
tickets are not a high priority. |
|---|
| 277 |
|
|---|
| 278 |
5. If a ticket has an associated patch (see below), a triager will review |
|---|
| 279 |
the patch. If the patch is complete, it'll be marked as "ready for |
|---|
| 280 |
checkin" so that a core developer knows to review and check in the |
|---|
| 281 |
patches. |
|---|
| 282 |
|
|---|
| 283 |
The second part of this workflow involves a set of flags the describe what the |
|---|
| 284 |
ticket has or needs in order to be "ready for checkin": |
|---|
| 285 |
|
|---|
| 286 |
"Has patch" |
|---|
| 287 |
This means the ticket has an associated patch_. These will be |
|---|
| 288 |
reviewed by the triage team to see if the patch is "good". |
|---|
| 289 |
|
|---|
| 290 |
"Needs documentation" |
|---|
| 291 |
This flag is used for tickets with patches that need associated |
|---|
| 292 |
documentation. Complete documentation of features is a prerequisite |
|---|
| 293 |
before we can check a fix into the codebase. |
|---|
| 294 |
|
|---|
| 295 |
"Needs tests" |
|---|
| 296 |
This flags the patch as needing associated unit tests. Again, this is a |
|---|
| 297 |
required part of a valid patch. |
|---|
| 298 |
|
|---|
| 299 |
"Patch needs improvement" |
|---|
| 300 |
This flag means that although the ticket *has* a patch, it's not quite |
|---|
| 301 |
ready for checkin. This could mean the patch no longer applies |
|---|
| 302 |
cleanly, or that the code doesn't live up to our standards. |
|---|
| 303 |
|
|---|
| 304 |
A ticket can be resolved in a number of ways: |
|---|
| 305 |
|
|---|
| 306 |
"fixed" |
|---|
| 307 |
Used by one of the core developers once a patch has been rolled into |
|---|
| 308 |
Django and the issue is fixed. |
|---|
| 309 |
|
|---|
| 310 |
"invalid" |
|---|
| 311 |
Used if the ticket is found to be incorrect. This means that the |
|---|
| 312 |
issue in the ticket is actually the result of a user error, or |
|---|
| 313 |
describes a problem with something other than Django, or isn't |
|---|
| 314 |
a bug report or feature request at all (for example, some new users |
|---|
| 315 |
submit support queries as tickets). |
|---|
| 316 |
|
|---|
| 317 |
"wontfix" |
|---|
| 318 |
Used when a core developer decides that this request is not |
|---|
| 319 |
appropriate for consideration in Django. This is usually chosen after |
|---|
| 320 |
discussion in the ``django-developers`` mailing list, and you should |
|---|
| 321 |
feel free to join in when it's something you care about. |
|---|
| 322 |
|
|---|
| 323 |
"duplicate" |
|---|
| 324 |
Used when another ticket covers the same issue. By closing duplicate |
|---|
| 325 |
tickets, we keep all the discussion in one place, which helps everyone. |
|---|
| 326 |
|
|---|
| 327 |
"worksforme" |
|---|
| 328 |
Used when the ticket doesn't contain enough detail to replicate |
|---|
| 329 |
the original bug. |
|---|
| 330 |
|
|---|
| 331 |
If you believe that the ticket was closed in error -- because you're |
|---|
| 332 |
still having the issue, or it's popped up somewhere else, or the triagers have |
|---|
| 333 |
-- made a mistake, please reopen the ticket and tell us why. Please do not |
|---|
| 334 |
reopen tickets that have been marked as "wontfix" by core developers. |
|---|
| 335 |
|
|---|
| 336 |
.. _required details: `Reporting bugs`_ |
|---|
| 337 |
.. _good patch: `Patch style`_ |
|---|
| 338 |
.. _patch: `Submitting patches`_ |
|---|
| 339 |
|
|---|
| 340 |
Triage by the general community |
|---|
| 341 |
------------------------------- |
|---|
| 342 |
|
|---|
| 343 |
Although the core developers and ticket triagers make the big decisions in |
|---|
| 344 |
the ticket triage process, there's also a lot that general community |
|---|
| 345 |
members can do to help the triage process. In particular, you can help out by: |
|---|
| 346 |
|
|---|
| 347 |
* Closing "Unreviewed" tickets as "invalid", "worksforme" or "duplicate." |
|---|
| 348 |
|
|---|
| 349 |
* Promoting "Unreviewed" tickets to "Design decision needed" if a design |
|---|
| 350 |
decision needs to be made, or "Accepted" in case of obvious bugs. |
|---|
| 351 |
|
|---|
| 352 |
* Correcting the "Needs tests", "Needs documentation", or "Has patch" flags |
|---|
| 353 |
for tickets where they are incorrectly set. |
|---|
| 354 |
|
|---|
| 355 |
* Checking that old tickets are still valid. If a ticket hasn't seen |
|---|
| 356 |
any activity in a long time, it's possible that the problem has been |
|---|
| 357 |
fixed but the ticket hasn't yet been closed. |
|---|
| 358 |
|
|---|
| 359 |
* Contacting the owners of tickets that have been claimed but have not seen |
|---|
| 360 |
any recent activity. If the owner doesn't respond after a week or so, |
|---|
| 361 |
remove the owner's claim on the ticket. |
|---|
| 362 |
|
|---|
| 363 |
* Identifying trends and themes in the tickets. If there a lot of bug reports |
|---|
| 364 |
about a particular part of Django, it may indicate we should consider |
|---|
| 365 |
refactoring that part of the code. If a trend is emerging, you should |
|---|
| 366 |
raise it for discussion (referencing the relevant tickets) on |
|---|
| 367 |
`django-developers`_. |
|---|
| 368 |
|
|---|
| 369 |
However, we do ask the following of all general community members working in |
|---|
| 370 |
the ticket database: |
|---|
| 371 |
|
|---|
| 372 |
* Please **don't** close tickets as "wontfix." The core developers will |
|---|
| 373 |
make the final determination of the fate of a ticket, usually after |
|---|
| 374 |
consultation with the community. |
|---|
| 375 |
|
|---|
| 376 |
* Please **don't** promote tickets to "Ready for checkin" unless they are |
|---|
| 377 |
*trivial* changes -- for example, spelling mistakes or broken links in |
|---|
| 378 |
documentation. |
|---|
| 379 |
|
|---|
| 380 |
* Please **don't** reverse a decision that has been made by a core |
|---|
| 381 |
developer. If you disagree with a discussion that has been made, |
|---|
| 382 |
please post a message to `django-developers`_. |
|---|
| 383 |
|
|---|
| 384 |
* Please be conservative in your actions. If you're unsure if you should |
|---|
| 385 |
be making a change, don't make the change -- leave a comment with your |
|---|
| 386 |
concerns on the ticket, or post a message to `django-developers`_. |
|---|
| 387 |
|
|---|
| 388 |
.. _contributing-translations: |
|---|
| 389 |
|
|---|
| 390 |
Submitting and maintaining translations |
|---|
| 391 |
======================================= |
|---|
| 392 |
|
|---|
| 393 |
Various parts of Django, such as the admin site and validation error messages, |
|---|
| 394 |
are internationalized. This means they display different text depending on a |
|---|
| 395 |
user's language setting. For this, Django uses the same internationalization |
|---|
| 396 |
infrastructure that is available to Django applications that is described |
|---|
| 397 |
in the :ref:`i18n documentation<topics-i18n>`. |
|---|
| 398 |
|
|---|
| 399 |
These translations are contributed by Django users worldwide. If you find an |
|---|
| 400 |
incorrect translation, or if you'd like to add a language that isn't yet |
|---|
| 401 |
translated, here's what to do: |
|---|
| 402 |
|
|---|
| 403 |
* Join the `Django i18n mailing list`_ and introduce yourself. |
|---|
| 404 |
|
|---|
| 405 |
* Create translations using the methods described in the |
|---|
| 406 |
:ref:`i18n documentation <topics-i18n>`. For this you will use the |
|---|
| 407 |
``django-admin.py makemessages`` tool. In this particular case it should |
|---|
| 408 |
be run from the top-level ``django`` directory of the Django source tree. |
|---|
| 409 |
|
|---|
| 410 |
The script runs over the entire Django source tree and pulls out all |
|---|
| 411 |
strings marked for translation. It creates (or updates) a message file in |
|---|
| 412 |
the directory ``conf/locale`` (for example for ``pt-BR``, the file will be |
|---|
| 413 |
``conf/locale/pt-br/LC_MESSAGES/django.po``). |
|---|
| 414 |
|
|---|
| 415 |
* Make sure that ``django-admin.py compilemessages -l <lang>`` runs without |
|---|
| 416 |
producing any warnings. |
|---|
| 417 |
|
|---|
| 418 |
* Repeat the last two steps for the ``djangojs`` domain (by appending the |
|---|
| 419 |
``-d djangojs`` command line option to the ``django-admin.py`` |
|---|
| 420 |
invocations). |
|---|
| 421 |
|
|---|
| 422 |
* Create a diff of the ``.po`` file(s) against the current Subversion trunk. |
|---|
| 423 |
|
|---|
| 424 |
* Open a ticket in Django's ticket system, set its ``Component`` field to |
|---|
| 425 |
``Translations``, and attach the patch to it. |
|---|
| 426 |
|
|---|
| 427 |
.. _Django i18n mailing list: http://groups.google.com/group/django-i18n/ |
|---|
| 428 |
|
|---|
| 429 |
Coding style |
|---|
| 430 |
============ |
|---|
| 431 |
|
|---|
| 432 |
Please follow these coding standards when writing code for inclusion in Django: |
|---|
| 433 |
|
|---|
| 434 |
* Unless otherwise specified, follow :pep:`8`. |
|---|
| 435 |
|
|---|
| 436 |
You could use a tool like `pep8.py`_ to check for some problems in this |
|---|
| 437 |
area, but remember that PEP 8 is only a guide, so respect the style of |
|---|
| 438 |
the surrounding code as a primary goal. |
|---|
| 439 |
|
|---|
| 440 |
* Use four spaces for indentation. |
|---|
| 441 |
|
|---|
| 442 |
* Use underscores, not camelCase, for variable, function and method names |
|---|
| 443 |
(i.e. ``poll.get_unique_voters()``, not ``poll.getUniqueVoters``). |
|---|
| 444 |
|
|---|
| 445 |
* Use ``InitialCaps`` for class names (or for factory functions that |
|---|
| 446 |
return classes). |
|---|
| 447 |
|
|---|
| 448 |
* Mark all strings for internationalization; see the :ref:`i18n |
|---|
| 449 |
documentation <topics-i18n>` for details. |
|---|
| 450 |
|
|---|
| 451 |
* In docstrings, use "action words" such as:: |
|---|
| 452 |
|
|---|
| 453 |
def foo(): |
|---|
| 454 |
""" |
|---|
| 455 |
Calculates something and returns the result. |
|---|
| 456 |
""" |
|---|
| 457 |
pass |
|---|
| 458 |
|
|---|
| 459 |
Here's an example of what not to do:: |
|---|
| 460 |
|
|---|
| 461 |
def foo(): |
|---|
| 462 |
""" |
|---|
| 463 |
Calculate something and return the result. |
|---|
| 464 |
""" |
|---|
| 465 |
pass |
|---|
| 466 |
|
|---|
| 467 |
* Please don't put your name in the code you contribute. Our policy is to |
|---|
| 468 |
keep contributors' names in the ``AUTHORS`` file distributed with Django |
|---|
| 469 |
-- not scattered throughout the codebase itself. Feel free to include a |
|---|
| 470 |
change to the ``AUTHORS`` file in your patch if you make more than a |
|---|
| 471 |
single trivial change. |
|---|
| 472 |
|
|---|
| 473 |
Template style |
|---|
| 474 |
-------------- |
|---|
| 475 |
|
|---|
| 476 |
* In Django template code, put one (and only one) space between the curly |
|---|
| 477 |
brackets and the tag contents. |
|---|
| 478 |
|
|---|
| 479 |
Do this: |
|---|
| 480 |
|
|---|
| 481 |
.. code-block:: html+django |
|---|
| 482 |
|
|---|
| 483 |
{{ foo }} |
|---|
| 484 |
|
|---|
| 485 |
Don't do this: |
|---|
| 486 |
|
|---|
| 487 |
.. code-block:: html+django |
|---|
| 488 |
|
|---|
| 489 |
{{foo}} |
|---|
| 490 |
|
|---|
| 491 |
View style |
|---|
| 492 |
---------- |
|---|
| 493 |
|
|---|
| 494 |
* In Django views, the first parameter in a view function should be called |
|---|
| 495 |
``request``. |
|---|
| 496 |
|
|---|
| 497 |
Do this:: |
|---|
| 498 |
|
|---|
| 499 |
def my_view(request, foo): |
|---|
| 500 |
# ... |
|---|
| 501 |
|
|---|
| 502 |
Don't do this:: |
|---|
| 503 |
|
|---|
| 504 |
def my_view(req, foo): |
|---|
| 505 |
# ... |
|---|
| 506 |
|
|---|
| 507 |
Model style |
|---|
| 508 |
----------- |
|---|
| 509 |
|
|---|
| 510 |
* Field names should be all lowercase, using underscores instead of |
|---|
| 511 |
camelCase. |
|---|
| 512 |
|
|---|
| 513 |
Do this:: |
|---|
| 514 |
|
|---|
| 515 |
class Person(models.Model): |
|---|
| 516 |
first_name = models.CharField(max_length=20) |
|---|
| 517 |
last_name = models.CharField(max_length=40) |
|---|
| 518 |
|
|---|
| 519 |
Don't do this:: |
|---|
| 520 |
|
|---|
| 521 |
class Person(models.Model): |
|---|
| 522 |
FirstName = models.CharField(max_length=20) |
|---|
| 523 |
Last_Name = models.CharField(max_length=40) |
|---|
| 524 |
|
|---|
| 525 |
* The ``class Meta`` should appear *after* the fields are defined, with |
|---|
| 526 |
a single blank line separating the fields and the class definition. |
|---|
| 527 |
|
|---|
| 528 |
Do this:: |
|---|
| 529 |
|
|---|
| 530 |
class Person(models.Model): |
|---|
| 531 |
first_name = models.CharField(max_length=20) |
|---|
| 532 |
last_name = models.CharField(max_length=40) |
|---|
| 533 |
|
|---|
| 534 |
class Meta: |
|---|
| 535 |
verbose_name_plural = 'people' |
|---|
| 536 |
|
|---|
| 537 |
Don't do this:: |
|---|
| 538 |
|
|---|
| 539 |
class Person(models.Model): |
|---|
| 540 |
first_name = models.CharField(max_length=20) |
|---|
| 541 |
last_name = models.CharField(max_length=40) |
|---|
| 542 |
class Meta: |
|---|
| 543 |
verbose_name_plural = 'people' |
|---|
| 544 |
|
|---|
| 545 |
Don't do this, either:: |
|---|
| 546 |
|
|---|
| 547 |
class Person(models.Model): |
|---|
| 548 |
class Meta: |
|---|
| 549 |
verbose_name_plural = 'people' |
|---|
| 550 |
|
|---|
| 551 |
first_name = models.CharField(max_length=20) |
|---|
| 552 |
last_name = models.CharField(max_length=40) |
|---|
| 553 |
|
|---|
| 554 |
* The order of model inner classes and standard methods should be as |
|---|
| 555 |
follows (noting that these are not all required): |
|---|
| 556 |
|
|---|
| 557 |
* All database fields |
|---|
| 558 |
* Custom manager attributes |
|---|
| 559 |
* ``class Meta`` |
|---|
| 560 |
* ``def __unicode__()`` |
|---|
| 561 |
* ``def __str__()`` |
|---|
| 562 |
* ``def save()`` |
|---|
| 563 |
* ``def get_absolute_url()`` |
|---|
| 564 |
* Any custom methods |
|---|
| 565 |
|
|---|
| 566 |
* If ``choices`` is defined for a given model field, define the choices as |
|---|
| 567 |
a tuple of tuples, with an all-uppercase name, either near the top of the |
|---|
| 568 |
model module or just above the model class. Example:: |
|---|
| 569 |
|
|---|
| 570 |
GENDER_CHOICES = ( |
|---|
| 571 |
('M', 'Male'), |
|---|
| 572 |
('F', 'Female'), |
|---|
| 573 |
) |
|---|
| 574 |
|
|---|
| 575 |
Documentation style |
|---|
| 576 |
=================== |
|---|
| 577 |
|
|---|
| 578 |
We place a high importance on consistency and readability of documentation. |
|---|
| 579 |
(After all, Django was created in a journalism environment!) |
|---|
| 580 |
|
|---|
| 581 |
How to document new features |
|---|
| 582 |
---------------------------- |
|---|
| 583 |
|
|---|
| 584 |
We treat our documentation like we treat our code: we aim to improve it as |
|---|
| 585 |
often as possible. This section explains how writers can craft their |
|---|
| 586 |
documentation changes in the most useful and least error-prone ways. |
|---|
| 587 |
|
|---|
| 588 |
Documentation changes come in two forms: |
|---|
| 589 |
|
|---|
| 590 |
* General improvements -- Typo corrections, error fixes and better |
|---|
| 591 |
explanations through clearer writing and more examples. |
|---|
| 592 |
|
|---|
| 593 |
* New features -- Documentation of features that have been added to the |
|---|
| 594 |
framework since the last release. |
|---|
| 595 |
|
|---|
| 596 |
Our policy is: |
|---|
| 597 |
|
|---|
| 598 |
**All documentation of new features should be written in a way that clearly |
|---|
| 599 |
designates the features are only available in the Django development |
|---|
| 600 |
version. Assume documentation readers are using the latest release, not the |
|---|
| 601 |
development version.** |
|---|
| 602 |
|
|---|
| 603 |
Our preferred way for marking new features is by prefacing the features' |
|---|
| 604 |
documentation with: ".. versionadded:: X.Y", followed by an optional one line |
|---|
| 605 |
comment and a mandatory blank line. |
|---|
| 606 |
|
|---|
| 607 |
General improvements, or other changes to the APIs that should be emphasized |
|---|
| 608 |
should use the ".. versionchanged:: X.Y" directive (with the same format as the |
|---|
| 609 |
``versionadded`` mentioned above. |
|---|
| 610 |
|
|---|
| 611 |
There's a full page of information about the :ref:`Django documentation |
|---|
| 612 |
system <internals-documentation>` that you should read prior to working on the |
|---|
| 613 |
documentation. |
|---|
| 614 |
|
|---|
| 615 |
Guidelines for ReST files |
|---|
| 616 |
------------------------- |
|---|
| 617 |
|
|---|
| 618 |
These guidelines regulate the format of our ReST documentation: |
|---|
| 619 |
|
|---|
| 620 |
* In section titles, capitalize only initial words and proper nouns. |
|---|
| 621 |
|
|---|
| 622 |
* Wrap the documentation at 80 characters wide, unless a code example |
|---|
| 623 |
is significantly less readable when split over two lines, or for another |
|---|
| 624 |
good reason. |
|---|
| 625 |
|
|---|
| 626 |
Commonly used terms |
|---|
| 627 |
------------------- |
|---|
| 628 |
|
|---|
| 629 |
Here are some style guidelines on commonly used terms throughout the |
|---|
| 630 |
documentation: |
|---|
| 631 |
|
|---|
| 632 |
* **Django** -- when referring to the framework, capitalize Django. It is |
|---|
| 633 |
lowercase only in Python code and in the djangoproject.com logo. |
|---|
| 634 |
|
|---|
| 635 |
* **e-mail** -- it has a hyphen. |
|---|
| 636 |
|
|---|
| 637 |
* **MySQL** |
|---|
| 638 |
|
|---|
| 639 |
* **PostgreSQL** |
|---|
| 640 |
|
|---|
| 641 |
* **Python** -- when referring to the language, capitalize Python. |
|---|
| 642 |
|
|---|
| 643 |
* **realize**, **customize**, **initialize**, etc. -- use the American |
|---|
| 644 |
"ize" suffix, not "ise." |
|---|
| 645 |
|
|---|
| 646 |
* **SQLite** |
|---|
| 647 |
|
|---|
| 648 |
* **subclass** -- it's a single word without a hyphen, both as a verb |
|---|
| 649 |
("subclass that model") and as a noun ("create a subclass"). |
|---|
| 650 |
|
|---|
| 651 |
* **Web**, **World Wide Web**, **the Web** -- note Web is always |
|---|
| 652 |
capitalized when referring to the World Wide Web. |
|---|
| 653 |
|
|---|
| 654 |
* **Web site** -- use two words, with Web capitalized. |
|---|
| 655 |
|
|---|
| 656 |
Django-specific terminology |
|---|
| 657 |
--------------------------- |
|---|
| 658 |
|
|---|
| 659 |
* **model** -- it's not capitalized. |
|---|
| 660 |
|
|---|
| 661 |
* **template** -- it's not capitalized. |
|---|
| 662 |
|
|---|
| 663 |
* **URLconf** -- use three capitalized letters, with no space before |
|---|
| 664 |
"conf." |
|---|
| 665 |
|
|---|
| 666 |
* **view** -- it's not capitalized. |
|---|
| 667 |
|
|---|
| 668 |
Committing code |
|---|
| 669 |
=============== |
|---|
| 670 |
|
|---|
| 671 |
Please follow these guidelines when committing code to Django's Subversion |
|---|
| 672 |
repository: |
|---|
| 673 |
|
|---|
| 674 |
* For any medium-to-big changes, where "medium-to-big" is according to your |
|---|
| 675 |
judgment, please bring things up on the `django-developers`_ mailing list |
|---|
| 676 |
before making the change. |
|---|
| 677 |
|
|---|
| 678 |
If you bring something up on `django-developers`_ and nobody responds, |
|---|
| 679 |
please don't take that to mean your idea is great and should be |
|---|
| 680 |
implemented immediately because nobody contested it. Django's lead |
|---|
| 681 |
developers don't have a lot of time to read mailing-list discussions |
|---|
| 682 |
immediately, so you may have to wait a couple of days before getting a |
|---|
| 683 |
response. |
|---|
| 684 |
|
|---|
| 685 |
* Write detailed commit messages in the past tense, not present tense. |
|---|
| 686 |
|
|---|
| 687 |
* Good: "Fixed Unicode bug in RSS API." |
|---|
| 688 |
* Bad: "Fixes Unicode bug in RSS API." |
|---|
| 689 |
* Bad: "Fixing Unicode bug in RSS API." |
|---|
| 690 |
|
|---|
| 691 |
* For commits to a branch, prefix the commit message with the branch name. |
|---|
| 692 |
For example: "magic-removal: Added support for mind reading." |
|---|
| 693 |
|
|---|
| 694 |
* Limit commits to the most granular change that makes sense. This means, |
|---|
| 695 |
use frequent small commits rather than infrequent large commits. For |
|---|
| 696 |
example, if implementing feature X requires a small change to library Y, |
|---|
| 697 |
first commit the change to library Y, then commit feature X in a separate |
|---|
| 698 |
commit. This goes a *long way* in helping all core Django developers |
|---|
| 699 |
follow your changes. |
|---|
| 700 |
|
|---|
| 701 |
* Separate bug fixes from feature changes. |
|---|
| 702 |
|
|---|
| 703 |
Bug fixes need to be added to the current bugfix branch (e.g. the |
|---|
| 704 |
``1.0.X`` branch) as well as the current trunk. |
|---|
| 705 |
|
|---|
| 706 |
* If your commit closes a ticket in the Django `ticket tracker`_, begin |
|---|
| 707 |
your commit message with the text "Fixed #abc", where "abc" is the number |
|---|
| 708 |
of the ticket your commit fixes. Example: "Fixed #123 -- Added support |
|---|
| 709 |
for foo". We've rigged Subversion and Trac so that any commit message |
|---|
| 710 |
in that format will automatically close the referenced ticket and post a |
|---|
| 711 |
comment to it with the full commit message. |
|---|
| 712 |
|
|---|
| 713 |
If your commit closes a ticket and is in a branch, use the branch name |
|---|
| 714 |
first, then the "Fixed #abc." For example: |
|---|
| 715 |
"magic-removal: Fixed #123 -- Added whizbang feature." |
|---|
| 716 |
|
|---|
| 717 |
For the curious: We're using a `Trac post-commit hook`_ for this. |
|---|
| 718 |
|
|---|
| 719 |
.. _Trac post-commit hook: http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook |
|---|
| 720 |
|
|---|
| 721 |
* If your commit references a ticket in the Django `ticket tracker`_ but |
|---|
| 722 |
does *not* close the ticket, include the phrase "Refs #abc", where "abc" |
|---|
| 723 |
is the number of the ticket your commit references. We've rigged |
|---|
| 724 |
Subversion and Trac so that any commit message in that format will |
|---|
| 725 |
automatically post a comment to the appropriate ticket. |
|---|
| 726 |
|
|---|
| 727 |
Unit tests |
|---|
| 728 |
========== |
|---|
| 729 |
|
|---|
| 730 |
Django comes with a test suite of its own, in the ``tests`` directory of the |
|---|
| 731 |
Django tarball. It's our policy to make sure all tests pass at all times. |
|---|
| 732 |
|
|---|
| 733 |
The tests cover: |
|---|
| 734 |
|
|---|
| 735 |
* Models and the database API (``tests/modeltests/``). |
|---|
| 736 |
* Everything else in core Django code (``tests/regressiontests``) |
|---|
| 737 |
* Contrib apps (``django/contrib/<contribapp>/tests``, see below) |
|---|
| 738 |
|
|---|
| 739 |
We appreciate any and all contributions to the test suite! |
|---|
| 740 |
|
|---|
| 741 |
The Django tests all use the testing infrastructure that ships with Django for |
|---|
| 742 |
testing applications. See :ref:`Testing Django applications <topics-testing>` |
|---|
| 743 |
for an explanation of how to write new tests. |
|---|
| 744 |
|
|---|
| 745 |
Running the unit tests |
|---|
| 746 |
---------------------- |
|---|
| 747 |
|
|---|
| 748 |
To run the tests, ``cd`` to the ``tests/`` directory and type: |
|---|
| 749 |
|
|---|
| 750 |
.. code-block:: bash |
|---|
| 751 |
|
|---|
| 752 |
./runtests.py --settings=path.to.django.settings |
|---|
| 753 |
|
|---|
| 754 |
Yes, the unit tests need a settings module, but only for database connection |
|---|
| 755 |
info, with the ``DATABASE_ENGINE`` setting. |
|---|
| 756 |
|
|---|
| 757 |
If you're using the ``sqlite3`` database backend, no further settings are |
|---|
| 758 |
needed. A temporary database will be created in memory when running the tests. |
|---|
| 759 |
|
|---|
| 760 |
If you're using another backend: |
|---|
| 761 |
|
|---|
| 762 |
* Your :setting:`DATABASE_USER` setting needs to specify an existing user account |
|---|
| 763 |
for the database engine. |
|---|
| 764 |
|
|---|
| 765 |
* The :setting:`DATABASE_NAME` setting must be the name of an existing database to |
|---|
| 766 |
which the given user has permission to connect. The unit tests will not |
|---|
| 767 |
touch this database; the test runner creates a new database whose name is |
|---|
| 768 |
:setting:`DATABASE_NAME` prefixed with ``test_``, and this test database is |
|---|
| 769 |
deleted when the tests are finished. This means your user account needs |
|---|
| 770 |
permission to execute ``CREATE DATABASE``. |
|---|
| 771 |
|
|---|
| 772 |
You will also need to ensure that your database uses UTF-8 as the default |
|---|
| 773 |
character set. If your database server doesn't use UTF-8 as a default charset, |
|---|
| 774 |
you will need to include a value for ``TEST_DATABASE_CHARSET`` in your settings |
|---|
| 775 |
file. |
|---|
| 776 |
|
|---|
| 777 |
If you want to run the full suite of tests, you'll need to install a number of |
|---|
| 778 |
dependencies: |
|---|
| 779 |
|
|---|
| 780 |
* PyYAML_ |
|---|
| 781 |
* Markdown_ |
|---|
| 782 |
* Textile_ |
|---|
| 783 |
* Docutils_ |
|---|
| 784 |
* setuptools_ |
|---|
| 785 |
* memcached_, plus the either the python-memcached_ or cmemcached_ Python binding |
|---|
| 786 |
|
|---|
| 787 |
If you want to test the memcached cache backend, you will also need to define |
|---|
| 788 |
a :setting:`CACHE_BACKEND` setting that points at your memcached instance. |
|---|
| 789 |
|
|---|
| 790 |
Each of these dependencies is optional. If you're missing any of them, the |
|---|
| 791 |
associated tests will be skipped. |
|---|
| 792 |
|
|---|
| 793 |
.. _PyYAML: http://pyyaml.org/wiki/PyYAML |
|---|
| 794 |
.. _Markdown: http://pypi.python.org/pypi/Markdown/1.7 |
|---|
| 795 |
.. _Textile: http://pypi.python.org/pypi/textile |
|---|
| 796 |
.. _docutils: http://pypi.python.org/pypi/docutils/0.4 |
|---|
| 797 |
.. _setuptools: http://pypi.python.org/pypi/setuptools/ |
|---|
| 798 |
.. _memcached: http://www.danga.com/memcached/ |
|---|
| 799 |
.. _python-memcached: http://pypi.python.org/pypi/python-memcached/ |
|---|
| 800 |
.. _cmemcached: http://pypi.python.org/pypi/cmemcache |
|---|
| 801 |
|
|---|
| 802 |
To run a subset of the unit tests, append the names of the test modules to the |
|---|
| 803 |
``runtests.py`` command line. See the list of directories in |
|---|
| 804 |
``tests/modeltests`` and ``tests/regressiontests`` for module names. |
|---|
| 805 |
|
|---|
| 806 |
As an example, if Django is not in your ``PYTHONPATH``, you placed |
|---|
| 807 |
``settings.py`` in the ``tests/`` directory, and you'd like to only run tests |
|---|
| 808 |
for generic relations and internationalization, type: |
|---|
| 809 |
|
|---|
| 810 |
.. code-block:: bash |
|---|
| 811 |
|
|---|
| 812 |
PYTHONPATH=.. |
|---|
| 813 |
./runtests.py --settings=settings generic_relations i18n |
|---|
| 814 |
|
|---|
| 815 |
Contrib apps |
|---|
| 816 |
------------ |
|---|
| 817 |
|
|---|
| 818 |
Tests for apps in ``django/contrib/`` go in their respective directories under |
|---|
| 819 |
``django/contrib/``, in a ``tests.py`` file. (You can split the tests over |
|---|
| 820 |
multiple modules by using a ``tests`` directory in the normal Python way.) |
|---|
| 821 |
|
|---|
| 822 |
For the tests to be found, a ``models.py`` file must exist (it doesn't |
|---|
| 823 |
have to have anything in it). If you have URLs that need to be |
|---|
| 824 |
mapped, put them in ``tests/urls.py``. |
|---|
| 825 |
|
|---|
| 826 |
To run tests for just one contrib app (e.g. ``markup``), use the same |
|---|
| 827 |
method as above:: |
|---|
| 828 |
|
|---|
| 829 |
./runtests.py --settings=settings markup |
|---|
| 830 |
|
|---|
| 831 |
Requesting features |
|---|
| 832 |
=================== |
|---|
| 833 |
|
|---|
| 834 |
We're always trying to make Django better, and your feature requests are a key |
|---|
| 835 |
part of that. Here are some tips on how to most effectively make a request: |
|---|
| 836 |
|
|---|
| 837 |
* Request the feature on `django-developers`_, not in the ticket tracker; |
|---|
| 838 |
it'll get read more closely if it's on the mailing list. |
|---|
| 839 |
|
|---|
| 840 |
* Describe clearly and concisely what the missing feature is and how you'd |
|---|
| 841 |
like to see it implemented. Include example code (non-functional is OK) |
|---|
| 842 |
if possible. |
|---|
| 843 |
|
|---|
| 844 |
* Explain *why* you'd like the feature. In some cases this is obvious, but |
|---|
| 845 |
since Django is designed to help real developers get real work done, |
|---|
| 846 |
you'll need to explain it, if it isn't obvious why the feature would be |
|---|
| 847 |
useful. |
|---|
| 848 |
|
|---|
| 849 |
As with most open-source projects, code talks. If you are willing to write the |
|---|
| 850 |
code for the feature yourself or if (even better) you've already written it, |
|---|
| 851 |
it's much more likely to be accepted. If it's a large feature that might need |
|---|
| 852 |
multiple developers we're always happy to give you an experimental branch in |
|---|
| 853 |
our repository; see below. |
|---|
| 854 |
|
|---|
| 855 |
Branch policy |
|---|
| 856 |
============= |
|---|
| 857 |
|
|---|
| 858 |
In general, the trunk must be kept stable. People should be able to run |
|---|
| 859 |
production sites against the trunk at any time. Additionally, commits to trunk |
|---|
| 860 |
ought to be as atomic as possible -- smaller changes are better. Thus, large |
|---|
| 861 |
feature changes -- that is, changes too large to be encapsulated in a single |
|---|
| 862 |
patch, or changes that need multiple eyes on them -- must happen on dedicated |
|---|
| 863 |
branches. |
|---|
| 864 |
|
|---|
| 865 |
This means that if you want to work on a large feature -- anything that would |
|---|
| 866 |
take more than a single patch, or requires large-scale refactoring -- you need |
|---|
| 867 |
to do it on a feature branch. Our development process recognizes two options |
|---|
| 868 |
for feature branches: |
|---|
| 869 |
|
|---|
| 870 |
1. Feature branches using a distributed revision control system like |
|---|
| 871 |
Git_, Mercurial_, Bazaar_, etc. |
|---|
| 872 |
|
|---|
| 873 |
If you're familiar with one of these tools, this is probably your best |
|---|
| 874 |
option since it doesn't require any support or buy-in from the Django |
|---|
| 875 |
core developers. |
|---|
| 876 |
|
|---|
| 877 |
However, do keep in mind that Django will continue to use Subversion for |
|---|
| 878 |
the foreseeable future, and this will naturally limit the recognition of |
|---|
| 879 |
your branch. Further, if your branch becomes eligible for merging to |
|---|
| 880 |
trunk you'll need to find a core developer familiar with your DVCS of |
|---|
| 881 |
choice who'll actually perform the merge. |
|---|
| 882 |
|
|---|
| 883 |
If you do decided to start a distributed branch of Django and choose to make it |
|---|
| 884 |
public, please add the branch to the `Django branches`_ wiki page. |
|---|
| 885 |
|
|---|
| 886 |
2. Feature branches using SVN have a higher bar. If you want a branch in SVN |
|---|
| 887 |
itself, you'll need a "mentor" among the :ref:`core committers |
|---|
| 888 |
<internals-committers>`. This person is responsible for actually creating |
|---|
| 889 |
the branch, monitoring your process (see below), and ultimately merging |
|---|
| 890 |
the branch into trunk. |
|---|
| 891 |
|
|---|
| 892 |
If you want a feature branch in SVN, you'll need to ask in |
|---|
| 893 |
`django-developers`_ for a mentor. |
|---|
| 894 |
|
|---|
| 895 |
.. _git: http://git.or.cz/ |
|---|
| 896 |
.. _mercurial: http://www.selenic.com/mercurial/ |
|---|
| 897 |
.. _bazaar: http://bazaar-vcs.org/ |
|---|
| 898 |
.. _django branches: http://code.djangoproject.com/wiki/DjangoBranches |
|---|
| 899 |
|
|---|
| 900 |
Branch rules |
|---|
| 901 |
------------ |
|---|
| 902 |
|
|---|
| 903 |
We've got a few rules for branches born out of experience with what makes a |
|---|
| 904 |
successful Django branch. |
|---|
| 905 |
|
|---|
| 906 |
DVCS branches are obviously not under central control, so we have no way of |
|---|
| 907 |
enforcing these rules. However, if you're using a DVCS, following these rules |
|---|
| 908 |
will give you the best chance of having a successful branch (read: merged back to |
|---|
| 909 |
trunk). |
|---|
| 910 |
|
|---|
| 911 |
Developers with branches in SVN, however, **must** follow these rules. The |
|---|
| 912 |
branch mentor will keep on eye on the branch and **will delete it** if these |
|---|
| 913 |
rules are broken. |
|---|
| 914 |
|
|---|
| 915 |
* Only branch entire copies of the Django tree, even if work is only |
|---|
| 916 |
happening on part of that tree. This makes it painless to switch to a |
|---|
| 917 |
branch. |
|---|
| 918 |
|
|---|
| 919 |
* Merge changes from trunk no less than once a week, and preferably every |
|---|
| 920 |
couple-three days. |
|---|
| 921 |
|
|---|
| 922 |
In our experience, doing regular trunk merges is often the difference |
|---|
| 923 |
between a successful branch and one that fizzles and dies. |
|---|
| 924 |
|
|---|
| 925 |
If you're working on an SVN branch, you should be using `svnmerge.py`_ |
|---|
| 926 |
to track merges from trunk. |
|---|
| 927 |
|
|---|
| 928 |
* Keep tests passing and documentation up-to-date. As with patches, |
|---|
| 929 |
we'll only merge a branch that comes with tests and documentation. |
|---|
| 930 |
|
|---|
| 931 |
.. _svnmerge.py: http://www.orcaware.com/svn/wiki/Svnmerge.py |
|---|
| 932 |
|
|---|
| 933 |
Once the branch is stable and ready to be merged into the trunk, alert |
|---|
| 934 |
`django-developers`_. |
|---|
| 935 |
|
|---|
| 936 |
After a branch has been merged, it should be considered "dead"; write access to |
|---|
| 937 |
it will be disabled, and old branches will be periodically "trimmed." To keep |
|---|
| 938 |
our SVN wrangling to a minimum, we won't be merging from a given branch into the |
|---|
| 939 |
trunk more than once. |
|---|
| 940 |
|
|---|
| 941 |
Using branches |
|---|
| 942 |
-------------- |
|---|
| 943 |
|
|---|
| 944 |
To use a branch, you'll need to do two things: |
|---|
| 945 |
|
|---|
| 946 |
* Get the branch's code through Subversion. |
|---|
| 947 |
|
|---|
| 948 |
* Point your Python ``site-packages`` directory at the branch's version of |
|---|
| 949 |
the ``django`` package rather than the version you already have |
|---|
| 950 |
installed. |
|---|
| 951 |
|
|---|
| 952 |
Getting the code from Subversion |
|---|
| 953 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 954 |
|
|---|
| 955 |
To get the latest version of a branch's code, check it out using Subversion: |
|---|
| 956 |
|
|---|
| 957 |
.. code-block:: bash |
|---|
| 958 |
|
|---|
| 959 |
svn co http://code.djangoproject.com/svn/django/branches/<branch>/ |
|---|
| 960 |
|
|---|
| 961 |
...where ``<branch>`` is the branch's name. See the `list of branch names`_. |
|---|
| 962 |
|
|---|
| 963 |
Alternatively, you can automatically convert an existing directory of the |
|---|
| 964 |
Django source code as long as you've checked it out via Subversion. To do the |
|---|
| 965 |
conversion, execute this command from within your ``django`` directory: |
|---|
| 966 |
|
|---|
| 967 |
.. code-block:: bash |
|---|
| 968 |
|
|---|
| 969 |
svn switch http://code.djangoproject.com/svn/django/branches/<branch>/ |
|---|
| 970 |
|
|---|
| 971 |
The advantage of using ``svn switch`` instead of ``svn co`` is that the |
|---|
| 972 |
``switch`` command retains any changes you might have made to your local copy |
|---|
| 973 |
of the code. It attempts to merge those changes into the "switched" code. The |
|---|
| 974 |
disadvantage is that it may cause conflicts with your local changes if the |
|---|
| 975 |
"switched" code has altered the same lines of code. |
|---|
| 976 |
|
|---|
| 977 |
(Note that if you use ``svn switch``, you don't need to point Python at the new |
|---|
| 978 |
version, as explained in the next section.) |
|---|
| 979 |
|
|---|
| 980 |
.. _list of branch names: http://code.djangoproject.com/browser/django/branches |
|---|
| 981 |
|
|---|
| 982 |
Pointing Python at the new Django version |
|---|
| 983 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 984 |
|
|---|
| 985 |
Once you've retrieved the branch's code, you'll need to change your Python |
|---|
| 986 |
``site-packages`` directory so that it points to the branch version of the |
|---|
| 987 |
``django`` directory. (The ``site-packages`` directory is somewhere such as |
|---|
| 988 |
``/usr/lib/python2.4/site-packages`` or |
|---|
| 989 |
``/usr/local/lib/python2.4/site-packages`` or ``C:\Python\site-packages``.) |
|---|
| 990 |
|
|---|
| 991 |
The simplest way to do this is by renaming the old ``django`` directory to |
|---|
| 992 |
``django.OLD`` and moving the trunk version of the code into the directory |
|---|
| 993 |
and calling it ``django``. |
|---|
| 994 |
|
|---|
| 995 |
Alternatively, you can use a symlink called ``django`` that points to the |
|---|
| 996 |
location of the branch's ``django`` package. If you want to switch back, just |
|---|
| 997 |
change the symlink to point to the old code. |
|---|
| 998 |
|
|---|
| 999 |
A third option is to use a `path file`_ (``<something>.pth``) which should |
|---|
| 1000 |
work on all systems (including Windows, which doesn't have symlinks |
|---|
| 1001 |
available). First, make sure there are no files, directories or symlinks named |
|---|
| 1002 |
``django`` in your ``site-packages`` directory. Then create a text file named |
|---|
| 1003 |
``django.pth`` and save it to your ``site-packages`` directory. That file |
|---|
| 1004 |
should contain a path to your copy of Django on a single line and optional |
|---|
| 1005 |
comments. Here is an example that points to multiple branches. Just uncomment |
|---|
| 1006 |
the line for the branch you want to use ('Trunk' in this example) and make |
|---|
| 1007 |
sure all other lines are commented:: |
|---|
| 1008 |
|
|---|
| 1009 |
# Trunk is a svn checkout of: |
|---|
| 1010 |
# http://code.djangoproject.com/svn/django/trunk/ |
|---|
| 1011 |
# |
|---|
| 1012 |
/path/to/trunk |
|---|
| 1013 |
|
|---|
| 1014 |
# <branch> is a svn checkout of: |
|---|
| 1015 |
# http://code.djangoproject.com/svn/django/branches/<branch>/ |
|---|
| 1016 |
# |
|---|
| 1017 |
#/path/to/<branch> |
|---|
| 1018 |
|
|---|
| 1019 |
# On windows a path may look like this: |
|---|
| 1020 |
# C:/path/to/<branch> |
|---|
| 1021 |
|
|---|
| 1022 |
If you're using Django 0.95 or earlier and installed it using |
|---|
| 1023 |
``python setup.py install``, you'll have a directory called something like |
|---|
| 1024 |
``Django-0.95-py2.4.egg`` instead of ``django``. In this case, edit the file |
|---|
| 1025 |
``setuptools.pth`` and remove the line that references the Django ``.egg`` |
|---|
| 1026 |
file. Then copy the branch's version of the ``django`` directory into |
|---|
| 1027 |
``site-packages``. |
|---|
| 1028 |
|
|---|
| 1029 |
.. _path file: http://docs.python.org/lib/module-site.html |
|---|
| 1030 |
|
|---|
| 1031 |
Deciding on features |
|---|
| 1032 |
==================== |
|---|
| 1033 |
|
|---|
| 1034 |
Once a feature's been requested and discussed, eventually we'll have a decision |
|---|
| 1035 |
about whether to include the feature or drop it. |
|---|
| 1036 |
|
|---|
| 1037 |
Whenever possible, we strive for a rough consensus. To that end, we'll often |
|---|
| 1038 |
have informal votes on `django-developers`_ about a feature. In these votes we |
|---|
| 1039 |
follow the voting style invented by Apache and used on Python itself, where |
|---|
| 1040 |
votes are given as +1, +0, -0, or -1. Roughly translated, these votes mean: |
|---|
| 1041 |
|
|---|
| 1042 |
* +1: "I love the idea and I'm strongly committed to it." |
|---|
| 1043 |
|
|---|
| 1044 |
* +0: "Sounds OK to me." |
|---|
| 1045 |
|
|---|
| 1046 |
* -0: "I'm not thrilled, but I won't stand in the way." |
|---|
| 1047 |
|
|---|
| 1048 |
* -1: "I strongly disagree and would be very unhappy to see the idea turn |
|---|
| 1049 |
into reality." |
|---|
| 1050 |
|
|---|
| 1051 |
Although these votes on django-developers are informal, they'll be taken very |
|---|
| 1052 |
seriously. After a suitable voting period, if an obvious consensus arises |
|---|
| 1053 |
we'll follow the votes. |
|---|
| 1054 |
|
|---|
| 1055 |
However, consensus is not always possible. Tough decisions will be discussed by |
|---|
| 1056 |
all full committers and finally decided by the Benevolent Dictators for Life, |
|---|
| 1057 |
Adrian and Jacob. |
|---|
| 1058 |
|
|---|
| 1059 |
Commit access |
|---|
| 1060 |
============= |
|---|
| 1061 |
|
|---|
| 1062 |
Django has two types of committers: |
|---|
| 1063 |
|
|---|
| 1064 |
Full committers |
|---|
| 1065 |
These are people who have a long history of contributions to Django's |
|---|
| 1066 |
codebase, a solid track record of being polite and helpful on the mailing |
|---|
| 1067 |
lists, and a proven desire to dedicate serious time to Django's development. |
|---|
| 1068 |
|
|---|
| 1069 |
The bar is very high for full commit access. It will only be granted by |
|---|
| 1070 |
unanimous approval of all existing full committers, and the decision will err |
|---|
| 1071 |
on the side of rejection. |
|---|
| 1072 |
|
|---|
| 1073 |
Partial committers |
|---|
| 1074 |
These are people who are "domain experts." They have direct check-in access |
|---|
| 1075 |
to the subsystems that fall under their jurisdiction, and they're given a |
|---|
| 1076 |
formal vote in questions that involve their subsystems. This type of access |
|---|
| 1077 |
is likely to be given to someone who contributes a large subframework to |
|---|
| 1078 |
Django and wants to continue to maintain it. |
|---|
| 1079 |
|
|---|
| 1080 |
Like full committers, partial commit access is by unanimous approval of all |
|---|
| 1081 |
full committers (and any other partial committers in the same area). |
|---|
| 1082 |
However, the bar is set lower; proven expertise in the area in question is |
|---|
| 1083 |
likely to be sufficient. |
|---|
| 1084 |
|
|---|
| 1085 |
To request commit access, please contact an existing committer privately. Public |
|---|
| 1086 |
requests for commit access are potential flame-war starters, and will be ignored. |
|---|
| 1087 |
|
|---|
| 1088 |
.. _community page: http://www.djangoproject.com/community/ |
|---|
| 1089 |
.. _ticket tracker: http://code.djangoproject.com/newticket |
|---|
| 1090 |
.. _django-developers: http://groups.google.com/group/django-developers |
|---|
| 1091 |
.. _search the tracker: http://code.djangoproject.com/search |
|---|
| 1092 |
.. _django-users: http://groups.google.com/group/django-users |
|---|
| 1093 |
.. _`#django`: irc://irc.freenode.net/django |
|---|
| 1094 |
.. _list of tickets with patches: http://code.djangoproject.com/query?status=new&status=assigned&status=reopened&has_patch=1&order=priority |
|---|
| 1095 |
.. _pep8.py: http://svn.browsershots.org/trunk/devtools/pep8/pep8.py |
|---|
| 1096 |
.. _i18n branch: http://code.djangoproject.com/browser/django/branches/i18n |
|---|
| 1097 |
.. _`tags/releases`: http://code.djangoproject.com/browser/django/tags/releases |
|---|