| 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 |
* Check the "Has patch" box on the ticket details. This will make it |
|---|
| 126 |
obvious that the ticket includes a patch, and it will add the ticket to |
|---|
| 127 |
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 |
|---|
| 155 |
users. A couple of dedicated volunteers work on this regularly, but more help |
|---|
| 156 |
is always appreciated. |
|---|
| 157 |
|
|---|
| 158 |
Most of the workflow is based around the concept of a ticket's "triage stage". |
|---|
| 159 |
This stage describes where in its lifetime a given ticket is at any time. |
|---|
| 160 |
Along with a handful of flags, this field easily tells us what and who each |
|---|
| 161 |
ticket is waiting on. |
|---|
| 162 |
|
|---|
| 163 |
Since a picture is worth a thousand words, let's start there: |
|---|
| 164 |
|
|---|
| 165 |
.. image:: http://media.djangoproject.com/img/doc/djangotickets.png |
|---|
| 166 |
:height: 451 |
|---|
| 167 |
:width: 590 |
|---|
| 168 |
:alt: Django's ticket workflow |
|---|
| 169 |
|
|---|
| 170 |
We've got two roles here: |
|---|
| 171 |
|
|---|
| 172 |
* Core developers: people with commit access who make the decisions and |
|---|
| 173 |
write the bulk of the code. |
|---|
| 174 |
|
|---|
| 175 |
* Ticket triagers: community members who keep track of tickets, making |
|---|
| 176 |
sure the tickets are always categorized correctly. |
|---|
| 177 |
|
|---|
| 178 |
Second, note the four triage stages: |
|---|
| 179 |
|
|---|
| 180 |
1. A ticket starts as "Unreviewed", meaning that a triager has yet to |
|---|
| 181 |
examine the ticket and move it along. |
|---|
| 182 |
|
|---|
| 183 |
2. "Design decision needed" means "this concept requires a design |
|---|
| 184 |
decision," which should be discussed either in the ticket comments or on |
|---|
| 185 |
django-developers. |
|---|
| 186 |
|
|---|
| 187 |
3. Once a ticket is ruled to be approved for fixing, it's moved into the |
|---|
| 188 |
"Accepted" stage. This stage is where all the real work gets done. |
|---|
| 189 |
|
|---|
| 190 |
4. If a ticket has an associated patch (see below), a triager will review the |
|---|
| 191 |
patch. If the patch is complete, it'll be marked as "ready for checkin" so |
|---|
| 192 |
that a core developer knows to review and check in the patches. |
|---|
| 193 |
|
|---|
| 194 |
The second part of this workflow involves a set of flags the describe what the |
|---|
| 195 |
ticket has or needs in order to be "ready for checkin": |
|---|
| 196 |
|
|---|
| 197 |
"Has patch" |
|---|
| 198 |
This means the ticket has an associated patch_. These will be |
|---|
| 199 |
reviewed to see if the patch is "good". |
|---|
| 200 |
|
|---|
| 201 |
"Needs documentation" |
|---|
| 202 |
This flag is used for tickets with patches that need associated |
|---|
| 203 |
documentation. Complete documentation of features is a prerequisite |
|---|
| 204 |
before we can check a fix into the codebase. |
|---|
| 205 |
|
|---|
| 206 |
"Needs tests" |
|---|
| 207 |
This flags the patch as needing associated unit tests. Again, this is a |
|---|
| 208 |
required part of a valid patch. |
|---|
| 209 |
|
|---|
| 210 |
"Patch needs improvement" |
|---|
| 211 |
This flag means that although the ticket *has* a patch, it's not quite |
|---|
| 212 |
ready for checkin. This could mean the patch no longer applies |
|---|
| 213 |
cleanly, or that the code doesn't live up to our standards. |
|---|
| 214 |
|
|---|
| 215 |
A ticket can be resolved in a number of ways: |
|---|
| 216 |
|
|---|
| 217 |
"fixed" |
|---|
| 218 |
Used by one of the core developers once a patch has been rolled into |
|---|
| 219 |
Django and the issue is fixed. |
|---|
| 220 |
|
|---|
| 221 |
"invalid" |
|---|
| 222 |
Used if the ticket is found to be incorrect or a user error. |
|---|
| 223 |
|
|---|
| 224 |
"wontfix" |
|---|
| 225 |
Used when a core developer decides that this request is not |
|---|
| 226 |
appropriate for consideration in Django. This is usually chosen after |
|---|
| 227 |
discussion in the ``django-developers`` mailing list, and you should |
|---|
| 228 |
feel free to join in when it's something you care about. |
|---|
| 229 |
|
|---|
| 230 |
"duplicate" |
|---|
| 231 |
Used when another ticket covers the same issue. By closing duplicate |
|---|
| 232 |
tickets, we keep all the discussion in one place, which helps everyone. |
|---|
| 233 |
|
|---|
| 234 |
"worksforme" |
|---|
| 235 |
Used when the triage team is unable to replicate the original bug. |
|---|
| 236 |
|
|---|
| 237 |
If you believe that the ticket was closed in error -- because you're |
|---|
| 238 |
still having the issue, or it's popped up somewhere else, or the triagers have |
|---|
| 239 |
-- made a mistake, please reopen the ticket and tell us why. Please do not |
|---|
| 240 |
reopen tickets that have been marked as "wontfix" by core developers. |
|---|
| 241 |
|
|---|
| 242 |
.. _required details: `Reporting bugs`_ |
|---|
| 243 |
.. _good patch: `Patch style`_ |
|---|
| 244 |
.. _patch: `Submitting patches`_ |
|---|
| 245 |
|
|---|
| 246 |
Submitting and maintaining translations |
|---|
| 247 |
======================================= |
|---|
| 248 |
|
|---|
| 249 |
Various parts of Django, such as the admin site and validator error messages, |
|---|
| 250 |
are internationalized. This means they display different text depending on a |
|---|
| 251 |
user's language setting. |
|---|
| 252 |
|
|---|
| 253 |
These translations are contributed by Django users worldwide. If you find an |
|---|
| 254 |
incorrect translation, or if you'd like to add a language that isn't yet |
|---|
| 255 |
translated, here's what to do: |
|---|
| 256 |
|
|---|
| 257 |
* Join the `Django i18n mailing list`_ and introduce yourself. |
|---|
| 258 |
* Create and submit translations using the methods described in the |
|---|
| 259 |
`i18n documentation`_. |
|---|
| 260 |
|
|---|
| 261 |
.. _Django i18n mailing list: http://groups.google.com/group/django-i18n/ |
|---|
| 262 |
.. _i18n documentation: ../i18n/ |
|---|
| 263 |
|
|---|
| 264 |
Coding style |
|---|
| 265 |
============ |
|---|
| 266 |
|
|---|
| 267 |
Please follow these coding standards when writing code for inclusion in Django: |
|---|
| 268 |
|
|---|
| 269 |
* Unless otherwise specified, follow `PEP 8`_. |
|---|
| 270 |
|
|---|
| 271 |
* Use four spaces for indentation. |
|---|
| 272 |
|
|---|
| 273 |
* Use underscores, not camelCase, for variable, function and method names |
|---|
| 274 |
(i.e. ``poll.get_unique_voters()``, not ``poll.getUniqueVoters``). |
|---|
| 275 |
|
|---|
| 276 |
* Use ``InitialCaps`` for class names (or for factory functions that |
|---|
| 277 |
return classes). |
|---|
| 278 |
|
|---|
| 279 |
* Mark all strings for internationalization; see the `i18n documentation`_ |
|---|
| 280 |
for details. |
|---|
| 281 |
|
|---|
| 282 |
* Please don't put your name in the code you contribute. Our policy is to |
|---|
| 283 |
keep contributors' names in the ``AUTHORS`` file distributed with Django |
|---|
| 284 |
-- not scattered throughout the codebase itself. Feel free to include a |
|---|
| 285 |
change to the ``AUTHORS`` file in your patch if you make more than a |
|---|
| 286 |
single trivial change. |
|---|
| 287 |
|
|---|
| 288 |
Template style |
|---|
| 289 |
-------------- |
|---|
| 290 |
|
|---|
| 291 |
* In Django template code, put one (and only one) space between the curly |
|---|
| 292 |
brackets and the tag contents. |
|---|
| 293 |
|
|---|
| 294 |
Do this:: |
|---|
| 295 |
|
|---|
| 296 |
{{ foo }} |
|---|
| 297 |
|
|---|
| 298 |
Don't do this:: |
|---|
| 299 |
|
|---|
| 300 |
{{foo}} |
|---|
| 301 |
|
|---|
| 302 |
View style |
|---|
| 303 |
---------- |
|---|
| 304 |
|
|---|
| 305 |
* In Django views, the first parameter in a view function should be called |
|---|
| 306 |
``request``. |
|---|
| 307 |
|
|---|
| 308 |
Do this:: |
|---|
| 309 |
|
|---|
| 310 |
def my_view(request, foo): |
|---|
| 311 |
# ... |
|---|
| 312 |
|
|---|
| 313 |
Don't do this:: |
|---|
| 314 |
|
|---|
| 315 |
def my_view(req, foo): |
|---|
| 316 |
# ... |
|---|
| 317 |
|
|---|
| 318 |
Model style |
|---|
| 319 |
----------- |
|---|
| 320 |
|
|---|
| 321 |
* Field names should be all lowercase, using underscores instead of |
|---|
| 322 |
camelCase. |
|---|
| 323 |
|
|---|
| 324 |
Do this:: |
|---|
| 325 |
|
|---|
| 326 |
class Person(models.Model): |
|---|
| 327 |
first_name = models.CharField(maxlength=20) |
|---|
| 328 |
last_name = models.CharField(maxlength=40) |
|---|
| 329 |
|
|---|
| 330 |
Don't do this:: |
|---|
| 331 |
|
|---|
| 332 |
class Person(models.Model): |
|---|
| 333 |
FirstName = models.CharField(maxlength=20) |
|---|
| 334 |
Last_Name = models.CharField(maxlength=40) |
|---|
| 335 |
|
|---|
| 336 |
* The ``class Meta`` should appear *after* the fields are defined, with |
|---|
| 337 |
a single blank line separating the fields and the class definition. |
|---|
| 338 |
|
|---|
| 339 |
Do this:: |
|---|
| 340 |
|
|---|
| 341 |
class Person(models.Model): |
|---|
| 342 |
first_name = models.CharField(maxlength=20) |
|---|
| 343 |
last_name = models.CharField(maxlength=40) |
|---|
| 344 |
|
|---|
| 345 |
class Meta: |
|---|
| 346 |
verbose_name_plural = 'people' |
|---|
| 347 |
|
|---|
| 348 |
Don't do this:: |
|---|
| 349 |
|
|---|
| 350 |
class Person(models.Model): |
|---|
| 351 |
first_name = models.CharField(maxlength=20) |
|---|
| 352 |
last_name = models.CharField(maxlength=40) |
|---|
| 353 |
class Meta: |
|---|
| 354 |
verbose_name_plural = 'people' |
|---|
| 355 |
|
|---|
| 356 |
Don't do this, either:: |
|---|
| 357 |
|
|---|
| 358 |
class Person(models.Model): |
|---|
| 359 |
class Meta: |
|---|
| 360 |
verbose_name_plural = 'people' |
|---|
| 361 |
|
|---|
| 362 |
first_name = models.CharField(maxlength=20) |
|---|
| 363 |
last_name = models.CharField(maxlength=40) |
|---|
| 364 |
|
|---|
| 365 |
* The order of model inner classes and standard methods should be as |
|---|
| 366 |
follows (noting that these are not all required): |
|---|
| 367 |
|
|---|
| 368 |
* All database fields |
|---|
| 369 |
* ``class Meta`` |
|---|
| 370 |
* ``class Admin`` |
|---|
| 371 |
* ``def __str__()`` |
|---|
| 372 |
* ``def save()`` |
|---|
| 373 |
* ``def get_absolute_url()`` |
|---|
| 374 |
* Any custom methods |
|---|
| 375 |
|
|---|
| 376 |
* If ``choices`` is defined for a given model field, define the choices as |
|---|
| 377 |
a tuple of tuples, with an all-uppercase name, either near the top of the |
|---|
| 378 |
model module or just above the model class. Example:: |
|---|
| 379 |
|
|---|
| 380 |
GENDER_CHOICES = ( |
|---|
| 381 |
('M', 'Male'), |
|---|
| 382 |
('F', 'Female'), |
|---|
| 383 |
) |
|---|
| 384 |
|
|---|
| 385 |
Committing code |
|---|
| 386 |
=============== |
|---|
| 387 |
|
|---|
| 388 |
Please follow these guidelines when committing code to Django's Subversion |
|---|
| 389 |
repository: |
|---|
| 390 |
|
|---|
| 391 |
* For any medium-to-big changes, where "medium-to-big" is according to your |
|---|
| 392 |
judgment, please bring things up on the `django-developers`_ mailing list |
|---|
| 393 |
before making the change. |
|---|
| 394 |
|
|---|
| 395 |
If you bring something up on `django-developers`_ and nobody responds, |
|---|
| 396 |
please don't take that to mean your idea is great and should be |
|---|
| 397 |
implemented immediately because nobody contested it. Django's lead |
|---|
| 398 |
developers don't have a lot of time to read mailing-list discussions |
|---|
| 399 |
immediately, so you may have to wait a couple of days before getting a |
|---|
| 400 |
response. |
|---|
| 401 |
|
|---|
| 402 |
* Write detailed commit messages in the past tense, not present tense. |
|---|
| 403 |
|
|---|
| 404 |
* Good: "Fixed Unicode bug in RSS API." |
|---|
| 405 |
* Bad: "Fixes Unicode bug in RSS API." |
|---|
| 406 |
* Bad: "Fixing Unicode bug in RSS API." |
|---|
| 407 |
|
|---|
| 408 |
* For commits to a branch, prefix the commit message with the branch name. |
|---|
| 409 |
For example: "magic-removal: Added support for mind reading." |
|---|
| 410 |
|
|---|
| 411 |
* Limit commits to the most granular change that makes sense. This means, |
|---|
| 412 |
use frequent small commits rather than infrequent large commits. For |
|---|
| 413 |
example, if implementing feature X requires a small change to library Y, |
|---|
| 414 |
first commit the change to library Y, then commit feature X in a separate |
|---|
| 415 |
commit. This goes a *long way* in helping all core Django developers |
|---|
| 416 |
follow your changes. |
|---|
| 417 |
|
|---|
| 418 |
* If your commit closes a ticket in the Django `ticket tracker`_, begin |
|---|
| 419 |
your commit message with the text "Fixed #abc", where "abc" is the number |
|---|
| 420 |
of the ticket your commit fixes. Example: "Fixed #123 -- Added support |
|---|
| 421 |
for foo". We've rigged Subversion and Trac so that any commit message |
|---|
| 422 |
in that format will automatically close the referenced ticket and post a |
|---|
| 423 |
comment to it with the full commit message. |
|---|
| 424 |
|
|---|
| 425 |
If your commit closes a ticket and is in a branch, use the branch name |
|---|
| 426 |
first, then the "Fixed #abc." For example: |
|---|
| 427 |
"magic-removal: Fixed #123 -- Added whizbang feature." |
|---|
| 428 |
|
|---|
| 429 |
For the curious: We're using a `Trac post-commit hook`_ for this. |
|---|
| 430 |
|
|---|
| 431 |
.. _Trac post-commit hook: http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook |
|---|
| 432 |
|
|---|
| 433 |
* If your commit references a ticket in the Django `ticket tracker`_ but |
|---|
| 434 |
does *not* close the ticket, include the phrase "Refs #abc", where "abc" |
|---|
| 435 |
is the number of the ticket your commit references. We've rigged |
|---|
| 436 |
Subversion and Trac so that any commit message in that format will |
|---|
| 437 |
automatically post a comment to the appropriate ticket. |
|---|
| 438 |
|
|---|
| 439 |
Unit tests |
|---|
| 440 |
========== |
|---|
| 441 |
|
|---|
| 442 |
Django comes with a test suite of its own, in the ``tests`` directory of the |
|---|
| 443 |
Django tarball. It's our policy to make sure all tests pass at all times. |
|---|
| 444 |
|
|---|
| 445 |
The tests cover: |
|---|
| 446 |
|
|---|
| 447 |
* Models and the database API (``tests/modeltests/``). |
|---|
| 448 |
* The cache system (``tests/regressiontests/cache.py``). |
|---|
| 449 |
* The ``django.utils.dateformat`` module (``tests/regressiontests/dateformat/``). |
|---|
| 450 |
* Database typecasts (``tests/regressiontests/db_typecasts/``). |
|---|
| 451 |
* The template system (``tests/regressiontests/templates/`` and |
|---|
| 452 |
``tests/regressiontests/defaultfilters/``). |
|---|
| 453 |
* ``QueryDict`` objects (``tests/regressiontests/httpwrappers/``). |
|---|
| 454 |
* Markup template tags (``tests/regressiontests/markup/``). |
|---|
| 455 |
|
|---|
| 456 |
We appreciate any and all contributions to the test suite! |
|---|
| 457 |
|
|---|
| 458 |
The Django tests all use the testing infrastructure that ships with Django for |
|---|
| 459 |
testing applications. See `Testing Django applications`_ for an explanation of |
|---|
| 460 |
how to write new tests. |
|---|
| 461 |
|
|---|
| 462 |
.. _Testing Django applications: ../testing/ |
|---|
| 463 |
|
|---|
| 464 |
Running the unit tests |
|---|
| 465 |
---------------------- |
|---|
| 466 |
|
|---|
| 467 |
To run the tests, ``cd`` to the ``tests/`` directory and type:: |
|---|
| 468 |
|
|---|
| 469 |
./runtests.py --settings=path.to.django.settings |
|---|
| 470 |
|
|---|
| 471 |
Yes, the unit tests need a settings module, but only for database connection |
|---|
| 472 |
info -- the ``DATABASE_NAME`` (required, but will be ignored), |
|---|
| 473 |
``DATABASE_ENGINE``, ``DATABASE_USER`` and ``DATABASE_PASSWORD`` settings. You |
|---|
| 474 |
will also need a ``ROOT_URLCONF`` setting (its value is ignored; it just needs |
|---|
| 475 |
to be present) and a ``SITE_ID`` setting (any integer value will do) in order |
|---|
| 476 |
for all the tests to pass. |
|---|
| 477 |
|
|---|
| 478 |
The unit tests will not touch your existing databases; they create a new |
|---|
| 479 |
database, called ``django_test_db``, which is deleted when the tests are |
|---|
| 480 |
finished. This means your user account needs permission to execute ``CREATE |
|---|
| 481 |
DATABASE``. |
|---|
| 482 |
|
|---|
| 483 |
Requesting features |
|---|
| 484 |
=================== |
|---|
| 485 |
|
|---|
| 486 |
We're always trying to make Django better, and your feature requests are a key |
|---|
| 487 |
part of that. Here are some tips on how to most effectively make a request: |
|---|
| 488 |
|
|---|
| 489 |
* Request the feature on `django-developers`_, not in the ticket tracker; |
|---|
| 490 |
it'll get read more closely if it's on the mailing list. |
|---|
| 491 |
|
|---|
| 492 |
* Describe clearly and concisely what the missing feature is and how you'd |
|---|
| 493 |
like to see it implemented. Include example code (non-functional is OK) |
|---|
| 494 |
if possible. |
|---|
| 495 |
|
|---|
| 496 |
* Explain *why* you'd like the feature. In some cases this is obvious, but |
|---|
| 497 |
since Django is designed to help real developers get real work done, |
|---|
| 498 |
you'll need to explain it, if it isn't obvious why the feature would be |
|---|
| 499 |
useful. |
|---|
| 500 |
|
|---|
| 501 |
As with most open-source projects, code talks. If you are willing to write the |
|---|
| 502 |
code for the feature yourself or if (even better) you've already written it, |
|---|
| 503 |
it's much more likely to be accepted. If it's a large feature that might need |
|---|
| 504 |
multiple developers we're always happy to give you an experimental branch in |
|---|
| 505 |
our repository; see below. |
|---|
| 506 |
|
|---|
| 507 |
Branch policy |
|---|
| 508 |
============= |
|---|
| 509 |
|
|---|
| 510 |
In general, most development is confined to the trunk, and the trunk |
|---|
| 511 |
is kept stable. People should be able to run production sites against the |
|---|
| 512 |
trunk at any time. |
|---|
| 513 |
|
|---|
| 514 |
Thus, large architectural changes -- that is, changes too large to be |
|---|
| 515 |
encapsulated in a single patch, or changes that need multiple eyes on them -- |
|---|
| 516 |
will have dedicated branches. See, for example, the `i18n branch`_. If you |
|---|
| 517 |
have a change of this nature that you'd like to work on, ask on |
|---|
| 518 |
`django-developers`_ for a branch to be created for you. We'll create a branch |
|---|
| 519 |
for pretty much any kind of experimenting you'd like to do. |
|---|
| 520 |
|
|---|
| 521 |
We will only branch entire copies of the Django tree, even if work is only |
|---|
| 522 |
happening on part of that tree. This makes it painless to switch to a branch. |
|---|
| 523 |
|
|---|
| 524 |
Developers working on a branch should periodically merge changes from the trunk |
|---|
| 525 |
into the branch. Please merge at least once a week. Every time you merge from |
|---|
| 526 |
the trunk, note the merge and revision numbers in the commit message. |
|---|
| 527 |
|
|---|
| 528 |
Once the branch is stable and ready to be merged into the trunk, alert |
|---|
| 529 |
`django-developers`_. |
|---|
| 530 |
|
|---|
| 531 |
After a branch has been merged, it should be considered "dead"; write access to |
|---|
| 532 |
it will be disabled, and old branches will be periodically "trimmed." To keep |
|---|
| 533 |
our SVN wrangling to a minimum, we won't be merging from a given branch into the |
|---|
| 534 |
trunk more than once. |
|---|
| 535 |
|
|---|
| 536 |
Using branches |
|---|
| 537 |
-------------- |
|---|
| 538 |
|
|---|
| 539 |
To use a branch, you'll need to do two things: |
|---|
| 540 |
|
|---|
| 541 |
* Get the branch's code through Subversion. |
|---|
| 542 |
|
|---|
| 543 |
* Point your Python ``site-packages`` directory at the branch's version of |
|---|
| 544 |
the ``django`` package rather than the version you already have |
|---|
| 545 |
installed. |
|---|
| 546 |
|
|---|
| 547 |
Getting the code from Subversion |
|---|
| 548 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 549 |
|
|---|
| 550 |
To get the latest version of a branch's code, check it out using Subversion:: |
|---|
| 551 |
|
|---|
| 552 |
svn co http://code.djangoproject.com/svn/django/branches/<branch>/ |
|---|
| 553 |
|
|---|
| 554 |
...where ``<branch>`` is the branch's name. See the `list of branch names`_. |
|---|
| 555 |
|
|---|
| 556 |
Alternatively, you can automatically convert an existing directory of the |
|---|
| 557 |
Django source code as long as you've checked it out via Subversion. To do the |
|---|
| 558 |
conversion, execute this command from within your ``django`` directory:: |
|---|
| 559 |
|
|---|
| 560 |
svn switch http://code.djangoproject.com/svn/django/branches/<branch>/ |
|---|
| 561 |
|
|---|
| 562 |
The advantage of using ``svn switch`` instead of ``svn co`` is that the |
|---|
| 563 |
``switch`` command retains any changes you might have made to your local copy |
|---|
| 564 |
of the code. It attempts to merge those changes into the "switched" code. The |
|---|
| 565 |
disadvantage is that it may cause conflicts with your local changes if the |
|---|
| 566 |
"switched" code has altered the same lines of code. |
|---|
| 567 |
|
|---|
| 568 |
(Note that if you use ``svn switch``, you don't need to point Python at the new |
|---|
| 569 |
version, as explained in the next section.) |
|---|
| 570 |
|
|---|
| 571 |
.. _list of branch names: http://code.djangoproject.com/browser/django/branches |
|---|
| 572 |
|
|---|
| 573 |
Pointing Python at the new Django version |
|---|
| 574 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 575 |
|
|---|
| 576 |
Once you've retrieved the branch's code, you'll need to change your Python |
|---|
| 577 |
``site-packages`` directory so that it points to the branch version of the |
|---|
| 578 |
``django`` directory. (The ``site-packages`` directory is somewhere such as |
|---|
| 579 |
``/usr/lib/python2.4/site-packages`` or |
|---|
| 580 |
``/usr/local/lib/python2.4/site-packages`` or ``C:\Python\site-packages``.) |
|---|
| 581 |
|
|---|
| 582 |
The simplest way to do this is by renaming the old ``django`` directory to |
|---|
| 583 |
``django.OLD`` and moving the trunk version of the code into the directory |
|---|
| 584 |
and calling it ``django``. |
|---|
| 585 |
|
|---|
| 586 |
Alternatively, you can use a symlink called ``django`` that points to the |
|---|
| 587 |
location of the branch's ``django`` package. If you want to switch back, just |
|---|
| 588 |
change the symlink to point to the old code. |
|---|
| 589 |
|
|---|
| 590 |
A third option is to use a `path file`_ (``<something>.pth``) which should |
|---|
| 591 |
work on all systems (including Windows, which doesn't have symlinks |
|---|
| 592 |
available). First, make sure there are no files, directories or symlinks named |
|---|
| 593 |
``django`` in your ``site-packages`` directory. Then create a text file named |
|---|
| 594 |
``django.pth`` and save it to your ``site-packages`` directory. That file |
|---|
| 595 |
should contain a path to your copy of Django on a single line and optional |
|---|
| 596 |
comments. Here is an example that points to multiple branches. Just uncomment |
|---|
| 597 |
the line for the branch you want to use ('Trunk' in this example) and make |
|---|
| 598 |
sure all other lines are commented:: |
|---|
| 599 |
|
|---|
| 600 |
# Trunk is a svn checkout of: |
|---|
| 601 |
# http://code.djangoproject.com/svn/django/trunk/ |
|---|
| 602 |
# |
|---|
| 603 |
/path/to/trunk |
|---|
| 604 |
|
|---|
| 605 |
# <branch> is a svn checkout of: |
|---|
| 606 |
# http://code.djangoproject.com/svn/django/branches/<branch>/ |
|---|
| 607 |
# |
|---|
| 608 |
#/path/to/<branch> |
|---|
| 609 |
|
|---|
| 610 |
# On windows a path may look like this: |
|---|
| 611 |
# C:/path/to/<branch> |
|---|
| 612 |
|
|---|
| 613 |
If you're using Django 0.95 or earlier and installed it using |
|---|
| 614 |
``python setup.py install``, you'll have a directory called something like |
|---|
| 615 |
``Django-0.95-py2.4.egg`` instead of ``django``. In this case, edit the file |
|---|
| 616 |
``setuptools.pth`` and remove the line that references the Django ``.egg`` |
|---|
| 617 |
file. Then copy the branch's version of the ``django`` directory into |
|---|
| 618 |
``site-packages``. |
|---|
| 619 |
|
|---|
| 620 |
.. _path file: http://docs.python.org/lib/module-site.html |
|---|
| 621 |
|
|---|
| 622 |
Official releases |
|---|
| 623 |
================= |
|---|
| 624 |
|
|---|
| 625 |
Django's release numbering works as follows: |
|---|
| 626 |
|
|---|
| 627 |
* Versions are numbered in the form ``A.B`` or ``A.B.C``. |
|---|
| 628 |
|
|---|
| 629 |
* ``A`` is the major version number, which is only incremented for major |
|---|
| 630 |
changes to Django, and these changes are not necessarily |
|---|
| 631 |
backwards-compatible. That is, code you wrote for Django 6.0 may break |
|---|
| 632 |
when we release Django 7.0. |
|---|
| 633 |
|
|---|
| 634 |
* ``B`` is the minor version number, which is incremented for large yet |
|---|
| 635 |
backwards compatible changes. Code written for Django 6.4 will continue |
|---|
| 636 |
to work under Django 6.5. |
|---|
| 637 |
|
|---|
| 638 |
A minor release may deprecate certain features in previous releases. If a |
|---|
| 639 |
feature in version ``A.B`` is deprecated, it will continue to work in |
|---|
| 640 |
version ``A.B+1``. In version ``A.B+2``, use of the feature will raise a |
|---|
| 641 |
``PendingDeprecationWarning`` but will continue to work. Version |
|---|
| 642 |
``A.B+3`` will remove the feature entirely. Major point releases will |
|---|
| 643 |
always remove deprecated features immediately. |
|---|
| 644 |
|
|---|
| 645 |
* ``C`` is the micro version number which, is incremented for bug and |
|---|
| 646 |
security fixes. A new micro-release will always be 100% |
|---|
| 647 |
backwards-compatible with the previous micro-release. |
|---|
| 648 |
|
|---|
| 649 |
* In some cases, we'll make release candidate releases. These are of the |
|---|
| 650 |
form ``A.BrcN``, which means the ``Nth`` candidate release of version |
|---|
| 651 |
``A.B``. |
|---|
| 652 |
|
|---|
| 653 |
An exception to this version numbering scheme is the pre-1.0 Django code. |
|---|
| 654 |
There's no guarantee of backwards-compatibility until the 1.0 release. |
|---|
| 655 |
|
|---|
| 656 |
In Subversion, each Django release will be tagged under `tags/releases`_. If |
|---|
| 657 |
it's necessary to release a bug fix release or a security release that doesn't |
|---|
| 658 |
come from the trunk, we'll copy that tag to ``branches/releases`` to make the |
|---|
| 659 |
bug fix release. |
|---|
| 660 |
|
|---|
| 661 |
Deciding on features |
|---|
| 662 |
==================== |
|---|
| 663 |
|
|---|
| 664 |
Once a feature's been requested and discussed, eventually we'll have a decision |
|---|
| 665 |
about whether to include the feature or drop it. |
|---|
| 666 |
|
|---|
| 667 |
Whenever possible, we strive for a rough consensus. To that end, we'll often |
|---|
| 668 |
have informal votes on `django-developers`_ about a feature. In these votes we |
|---|
| 669 |
follow the voting style invented by Apache and used on Python itself, where |
|---|
| 670 |
votes are given as +1, +0, -0, or -1. Roughly translated, these votes mean: |
|---|
| 671 |
|
|---|
| 672 |
* +1: "I love the idea and I'm strongly committed to it." |
|---|
| 673 |
|
|---|
| 674 |
* +0: "Sounds OK to me." |
|---|
| 675 |
|
|---|
| 676 |
* -0: "I'm not thrilled, but I won't stand in the way." |
|---|
| 677 |
|
|---|
| 678 |
* -1: "I strongly disagree and would be very unhappy to see the idea turn |
|---|
| 679 |
into reality." |
|---|
| 680 |
|
|---|
| 681 |
Although these votes on django-developers are informal, they'll be taken very |
|---|
| 682 |
seriously. After a suitable voting period, if an obvious consensus arises |
|---|
| 683 |
we'll follow the votes. |
|---|
| 684 |
|
|---|
| 685 |
However, consensus is not always possible. Tough decisions will be discussed by |
|---|
| 686 |
all full committers and finally decided by the Benevolent Dictators for Life, |
|---|
| 687 |
Adrian and Jacob. |
|---|
| 688 |
|
|---|
| 689 |
Commit access |
|---|
| 690 |
============= |
|---|
| 691 |
|
|---|
| 692 |
Django has two types of committers: |
|---|
| 693 |
|
|---|
| 694 |
Full committers |
|---|
| 695 |
These are people who have a long history of contributions to Django's |
|---|
| 696 |
codebase, a solid track record of being polite and helpful on the mailing |
|---|
| 697 |
lists, and a proven desire to dedicate serious time to Django's development. |
|---|
| 698 |
|
|---|
| 699 |
The bar is very high for full commit access. It will only be granted by |
|---|
| 700 |
unanimous approval of all existing full committers, and the decision will err |
|---|
| 701 |
on the side of rejection. |
|---|
| 702 |
|
|---|
| 703 |
Partial committers |
|---|
| 704 |
These are people who are "domain experts." They have direct check-in access |
|---|
| 705 |
to the subsystems that fall under their jurisdiction, and they're given a |
|---|
| 706 |
formal vote in questions that involve their subsystems. This type of access |
|---|
| 707 |
is likely to be given to someone who contributes a large subframework to |
|---|
| 708 |
Django and wants to continue to maintain it. |
|---|
| 709 |
|
|---|
| 710 |
Like full committers, partial commit access is by unanimous approval of all |
|---|
| 711 |
full committers (and any other partial committers in the same area). |
|---|
| 712 |
However, the bar is set lower; proven expertise in the area in question is |
|---|
| 713 |
likely to be sufficient. |
|---|
| 714 |
|
|---|
| 715 |
To request commit access, please contact an existing committer privately. Public |
|---|
| 716 |
requests for commit access are potential flame-war starters, and will be ignored. |
|---|
| 717 |
|
|---|
| 718 |
.. _community page: http://www.djangoproject.com/community/ |
|---|
| 719 |
.. _ticket tracker: http://code.djangoproject.com/newticket |
|---|
| 720 |
.. _django-developers: http://groups.google.com/group/django-developers |
|---|
| 721 |
.. _FAQ: http://www.djangoproject.com/documentation/faq/ |
|---|
| 722 |
.. _search the tracker: http://code.djangoproject.com/search |
|---|
| 723 |
.. _django-users: http://groups.google.com/group/django-users |
|---|
| 724 |
.. _`#django`: irc://irc.freenode.net/django |
|---|
| 725 |
.. _list of tickets with patches: http://code.djangoproject.com/query?status=new&status=assigned&status=reopened&has_patch=1&order=priority |
|---|
| 726 |
.. _PEP 8: http://www.python.org/peps/pep-0008.html |
|---|
| 727 |
.. _i18n branch: http://code.djangoproject.com/browser/django/branches/i18n |
|---|
| 728 |
.. _`tags/releases`: http://code.djangoproject.com/browser/django/tags/releases |
|---|