contributing.txt 42 KB

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