contributing.txt 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090
  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. Patches in ``git diff`` format are also acceptable.
  142. * When creating patches, always run ``svn diff`` from the top-level
  143. ``trunk`` directory -- i.e., the one that contains ``django``, ``docs``,
  144. ``tests``, ``AUTHORS``, etc. This makes it easy for other people to apply
  145. your patches.
  146. * Attach patches to a ticket in the `ticket tracker`_, using the "attach file"
  147. button. Please *don't* put the patch in the ticket description or comment
  148. unless it's a single line patch.
  149. * Name the patch file with a ``.diff`` extension; this will let the ticket
  150. tracker apply correct syntax highlighting, which is quite helpful.
  151. * Check the "Has patch" box on the ticket details. This will make it
  152. obvious that the ticket includes a patch, and it will add the ticket to
  153. the `list of tickets with patches`_.
  154. * The code required to fix a problem or add a feature is an essential part
  155. of a patch, but it is not the only part. A good patch should also include
  156. a regression test to validate the behavior that has been fixed (and prevent
  157. the problem from arising again).
  158. * If the code associated with a patch adds a new feature, or modifies behavior
  159. of an existing feature, the patch should also contain documentation.
  160. Non-trivial patches
  161. -------------------
  162. A "non-trivial" patch is one that is more than a simple bug fix. It's a patch
  163. that introduces Django functionality and makes some sort of design decision.
  164. If you provide a non-trivial patch, include evidence that alternatives have
  165. been discussed on `django-developers`_. If you're not sure whether your patch
  166. should be considered non-trivial, just ask.
  167. Ticket triage
  168. =============
  169. Unfortunately, not all bug reports in the `ticket tracker`_ provide all
  170. the `required details`_. A number of tickets have patches, but those patches
  171. don't meet all the requirements of a `good patch`_.
  172. One way to help out is to *triage* bugs that have been reported by other
  173. users. A couple of dedicated volunteers work on this regularly, but more help
  174. is always appreciated.
  175. Most of the workflow is based around the concept of a ticket's "triage stage".
  176. This stage describes where in its lifetime a given ticket is at any time.
  177. Along with a handful of flags, this field easily tells us what and who each
  178. ticket is waiting on.
  179. Since a picture is worth a thousand words, let's start there:
  180. .. image:: _images/djangotickets.png
  181. :height: 451
  182. :width: 590
  183. :alt: Django's ticket workflow
  184. We've got two official roles here:
  185. * Core developers: people with commit access who make the big decisions
  186. and write the bulk of the code.
  187. * Ticket triagers: trusted community members with a proven history of
  188. working with the Django community. As a result of this history, they
  189. have been entrusted by the core developers to make some of the smaller
  190. decisions about tickets.
  191. Second, note the five triage stages:
  192. 1. A ticket starts as "Unreviewed", meaning that nobody has examined
  193. the ticket.
  194. 2. "Design decision needed" means "this concept requires a design
  195. decision," which should be discussed either in the ticket comments or on
  196. `django-developers`_. The "Design decision needed" step will generally
  197. only be used for feature requests. It can also be used for issues
  198. that *might* be bugs, depending on opinion or interpretation. Obvious
  199. bugs (such as crashes, incorrect query results, or non-compliance with a
  200. standard) skip this step and move straight to "Accepted".
  201. 3. Once a ticket is ruled to be approved for fixing, it's moved into the
  202. "Accepted" stage. This stage is where all the real work gets done.
  203. 4. In some cases, a ticket might get moved to the "Someday/Maybe" state.
  204. This means the ticket is an enhancement request that we might consider
  205. adding to the framework if an excellent patch is submitted. These
  206. tickets are not a high priority.
  207. 5. If a ticket has an associated patch (see below), a triager will review
  208. the patch. If the patch is complete, it'll be marked as "ready for
  209. checkin" so that a core developer knows to review and check in the
  210. patches.
  211. The second part of this workflow involves a set of flags the describe what the
  212. ticket has or needs in order to be "ready for checkin":
  213. "Has patch"
  214. This means the ticket has an associated patch_. These will be
  215. reviewed by the triage team to see if the patch is "good".
  216. "Needs documentation"
  217. This flag is used for tickets with patches that need associated
  218. documentation. Complete documentation of features is a prerequisite
  219. before we can check a fix into the codebase.
  220. "Needs tests"
  221. This flags the patch as needing associated unit tests. Again, this is a
  222. required part of a valid patch.
  223. "Patch needs improvement"
  224. This flag means that although the ticket *has* a patch, it's not quite
  225. ready for checkin. This could mean the patch no longer applies
  226. cleanly, or that the code doesn't live up to our standards.
  227. A ticket can be resolved in a number of ways:
  228. "fixed"
  229. Used by one of the core developers once a patch has been rolled into
  230. Django and the issue is fixed.
  231. "invalid"
  232. Used if the ticket is found to be incorrect. This means that the
  233. issue in the ticket is actually the result of a user error, or
  234. describes a problem with something other than Django, or isn't
  235. a bug report or feature request at all (for example, some new users
  236. submit support queries as tickets).
  237. "wontfix"
  238. Used when a core developer decides that this request is not
  239. appropriate for consideration in Django. This is usually chosen after
  240. discussion in the ``django-developers`` mailing list, and you should
  241. feel free to join in when it's something you care about.
  242. "duplicate"
  243. Used when another ticket covers the same issue. By closing duplicate
  244. tickets, we keep all the discussion in one place, which helps everyone.
  245. "worksforme"
  246. Used when the the ticket doesn't contain enough detail to replicate
  247. the original bug.
  248. If you believe that the ticket was closed in error -- because you're
  249. still having the issue, or it's popped up somewhere else, or the triagers have
  250. -- made a mistake, please reopen the ticket and tell us why. Please do not
  251. reopen tickets that have been marked as "wontfix" by core developers.
  252. .. _required details: `Reporting bugs`_
  253. .. _good patch: `Patch style`_
  254. .. _patch: `Submitting patches`_
  255. Triage by the general community
  256. -------------------------------
  257. Although the core developers and ticket triagers make the big decisions in
  258. the ticket triage process, there's also a lot that general community
  259. members can do to help the triage process. In particular, you can help out by:
  260. * Closing "Unreviewed" tickets as "invalid", "worksforme" or "duplicate."
  261. * Promoting "Unreviewed" tickets to "Design decision needed" if a design
  262. decision needs to be made, or "Accepted" in case of obvious bugs.
  263. * Correcting the "Needs tests", "Needs documentation", or "Has patch" flags
  264. for tickets where they are incorrectly set.
  265. * Checking that old tickets are still valid. If a ticket hasn't seen
  266. any activity in a long time, it's possible that the problem has been
  267. fixed but the ticket hasn't yet been closed.
  268. * Contacting the owners of tickets that have been claimed but have not seen
  269. any recent activity. If the owner doesn't respond after a week or so,
  270. remove the owner's claim on the ticket.
  271. * Identifying trends and themes in the tickets. If there a lot of bug reports
  272. about a particular part of Django, it may indicate we should consider
  273. refactoring that part of the code. If a trend is emerging, you should
  274. raise it for discussion (referencing the relevant tickets) on
  275. `django-developers`_.
  276. However, we do ask the following of all general community members working in
  277. the ticket database:
  278. * Please **don't** close tickets as "wontfix." The core developers will
  279. make the final determination of the fate of a ticket, usually after
  280. consultation with the community.
  281. * Please **don't** promote tickets to "Ready for checkin" unless they are
  282. *trivial* changes -- for example, spelling mistakes or broken links in
  283. documentation.
  284. * Please **don't** reverse a decision that has been made by a core
  285. developer. If you disagree with a discussion that has been made,
  286. please post a message to `django-developers`_.
  287. * Please be conservative in your actions. If you're unsure if you should
  288. be making a change, don't make the change -- leave a comment with your
  289. concerns on the ticket, or post a message to `django-developers`_.
  290. .. _contributing-translations:
  291. Submitting and maintaining translations
  292. =======================================
  293. Various parts of Django, such as the admin site and validation error messages,
  294. are internationalized. This means they display different text depending on a
  295. user's language setting. For this, Django uses the same internationalization
  296. infrastructure that is available to Django applications that is described
  297. in the :ref:`i18n documentation<topics-i18n>`.
  298. These translations are contributed by Django users worldwide. If you find an
  299. incorrect translation, or if you'd like to add a language that isn't yet
  300. translated, here's what to do:
  301. * Join the `Django i18n mailing list`_ and introduce yourself.
  302. * Create translations using the methods described in the
  303. :ref:`i18n documentation <topics-i18n>`. For this you will use the
  304. ``django-admin.py makemessages`` tool. In this particular case it should
  305. be run from the top-level ``django`` directory of the Django source tree.
  306. The script runs over the entire Django source tree and pulls out all
  307. strings marked for translation. It creates (or updates) a message file in
  308. the directory ``conf/locale`` (for example for ``pt-BR``, the file will be
  309. ``conf/locale/pt-br/LC_MESSAGES/django.po``).
  310. * Make sure that ``django-admin.py compilemessages -l <lang>`` runs without
  311. producing any warnings.
  312. * Repeat the last two steps for the ``djangojs`` domain (by appending the
  313. ``-d djangojs`` command line option to the ``django-admin.py``
  314. invocations).
  315. * Create a diff of the ``.po`` file(s) against the current Subversion trunk.
  316. * Open a ticket in Django's ticket system, set its ``Component`` field to
  317. ``Translations``, and attach the patch to it.
  318. .. _Django i18n mailing list: http://groups.google.com/group/django-i18n/
  319. Coding style
  320. ============
  321. Please follow these coding standards when writing code for inclusion in Django:
  322. * Unless otherwise specified, follow :pep:`8`.
  323. You could use a tool like `pep8.py`_ to check for some problems in this
  324. area, but remember that PEP 8 is only a guide, so respect the style of
  325. the surrounding code as a primary goal.
  326. * Use four spaces for indentation.
  327. * Use underscores, not camelCase, for variable, function and method names
  328. (i.e. ``poll.get_unique_voters()``, not ``poll.getUniqueVoters``).
  329. * Use ``InitialCaps`` for class names (or for factory functions that
  330. return classes).
  331. * Mark all strings for internationalization; see the :ref:`i18n
  332. documentation <topics-i18n>` for details.
  333. * In docstrings, use "action words" such as::
  334. def foo():
  335. """
  336. Calculates something and returns the result.
  337. """
  338. pass
  339. Here's an example of what not to do::
  340. def foo():
  341. """
  342. Calculate something and return the result.
  343. """
  344. pass
  345. * Please don't put your name in the code you contribute. Our policy is to
  346. keep contributors' names in the ``AUTHORS`` file distributed with Django
  347. -- not scattered throughout the codebase itself. Feel free to include a
  348. change to the ``AUTHORS`` file in your patch if you make more than a
  349. single trivial change.
  350. Template style
  351. --------------
  352. * In Django template code, put one (and only one) space between the curly
  353. brackets and the tag contents.
  354. Do this:
  355. .. code-block:: html+django
  356. {{ foo }}
  357. Don't do this:
  358. .. code-block:: html+django
  359. {{foo}}
  360. View style
  361. ----------
  362. * In Django views, the first parameter in a view function should be called
  363. ``request``.
  364. Do this::
  365. def my_view(request, foo):
  366. # ...
  367. Don't do this::
  368. def my_view(req, foo):
  369. # ...
  370. Model style
  371. -----------
  372. * Field names should be all lowercase, using underscores instead of
  373. camelCase.
  374. Do this::
  375. class Person(models.Model):
  376. first_name = models.CharField(max_length=20)
  377. last_name = models.CharField(max_length=40)
  378. Don't do this::
  379. class Person(models.Model):
  380. FirstName = models.CharField(max_length=20)
  381. Last_Name = models.CharField(max_length=40)
  382. * The ``class Meta`` should appear *after* the fields are defined, with
  383. a single blank line separating the fields and the class definition.
  384. Do this::
  385. class Person(models.Model):
  386. first_name = models.CharField(max_length=20)
  387. last_name = models.CharField(max_length=40)
  388. class Meta:
  389. verbose_name_plural = 'people'
  390. Don't do this::
  391. class Person(models.Model):
  392. first_name = models.CharField(max_length=20)
  393. last_name = models.CharField(max_length=40)
  394. class Meta:
  395. verbose_name_plural = 'people'
  396. Don't do this, either::
  397. class Person(models.Model):
  398. class Meta:
  399. verbose_name_plural = 'people'
  400. first_name = models.CharField(max_length=20)
  401. last_name = models.CharField(max_length=40)
  402. * The order of model inner classes and standard methods should be as
  403. follows (noting that these are not all required):
  404. * All database fields
  405. * Custom manager attributes
  406. * ``class Meta``
  407. * ``def __unicode__()``
  408. * ``def __str__()``
  409. * ``def save()``
  410. * ``def get_absolute_url()``
  411. * Any custom methods
  412. * If ``choices`` is defined for a given model field, define the choices as
  413. a tuple of tuples, with an all-uppercase name, either near the top of the
  414. model module or just above the model class. Example::
  415. GENDER_CHOICES = (
  416. ('M', 'Male'),
  417. ('F', 'Female'),
  418. )
  419. Documentation style
  420. ===================
  421. We place a high importance on consistency and readability of documentation.
  422. (After all, Django was created in a journalism environment!)
  423. How to document new features
  424. ----------------------------
  425. We treat our documentation like we treat our code: we aim to improve it as
  426. often as possible. This section explains how writers can craft their
  427. documentation changes in the most useful and least error-prone ways.
  428. Documentation changes come in two forms:
  429. * General improvements -- Typo corrections, error fixes and better
  430. explanations through clearer writing and more examples.
  431. * New features -- Documentation of features that have been added to the
  432. framework since the last release.
  433. Our policy is:
  434. **All documentation of new features should be written in a way that clearly
  435. designates the features are only available in the Django development
  436. version. Assume documentation readers are using the latest release, not the
  437. development version.**
  438. Our preferred way for marking new features is by prefacing the features'
  439. documentation with: ".. versionadded:: X.Y", followed by an optional one line
  440. comment and a mandatory blank line.
  441. General improvements, or other changes to the APIs that should be emphasized
  442. should use the ".. versionchanged:: X.Y" directive (with the same format as the
  443. ``versionadded`` mentioned above.
  444. There's a full page of information about the :ref:`Django documentation
  445. system <internals-documentation>` that you should read prior to working on the
  446. documentation.
  447. Guidelines for ReST files
  448. -------------------------
  449. These guidelines regulate the format of our ReST documentation:
  450. * In section titles, capitalize only initial words and proper nouns.
  451. * Wrap the documentation at 80 characters wide, unless a code example
  452. is significantly less readable when split over two lines, or for another
  453. good reason.
  454. Commonly used terms
  455. -------------------
  456. Here are some style guidelines on commonly used terms throughout the
  457. documentation:
  458. * **Django** -- when referring to the framework, capitalize Django. It is
  459. lowercase only in Python code and in the djangoproject.com logo.
  460. * **e-mail** -- it has a hyphen.
  461. * **MySQL**
  462. * **PostgreSQL**
  463. * **Python** -- when referring to the language, capitalize Python.
  464. * **realize**, **customize**, **initialize**, etc. -- use the American
  465. "ize" suffix, not "ise."
  466. * **SQLite**
  467. * **subclass** -- it's a single word without a hyphen, both as a verb
  468. ("subclass that model") and as a noun ("create a subclass").
  469. * **Web**, **World Wide Web**, **the Web** -- note Web is always
  470. capitalized when referring to the World Wide Web.
  471. * **Web site** -- use two words, with Web capitalized.
  472. Django-specific terminology
  473. ---------------------------
  474. * **model** -- it's not capitalized.
  475. * **template** -- it's not capitalized.
  476. * **URLconf** -- use three capitalized letters, with no space before
  477. "conf."
  478. * **view** -- it's not capitalized.
  479. Committing code
  480. ===============
  481. Please follow these guidelines when committing code to Django's Subversion
  482. repository:
  483. * For any medium-to-big changes, where "medium-to-big" is according to your
  484. judgment, please bring things up on the `django-developers`_ mailing list
  485. before making the change.
  486. If you bring something up on `django-developers`_ and nobody responds,
  487. please don't take that to mean your idea is great and should be
  488. implemented immediately because nobody contested it. Django's lead
  489. developers don't have a lot of time to read mailing-list discussions
  490. immediately, so you may have to wait a couple of days before getting a
  491. response.
  492. * Write detailed commit messages in the past tense, not present tense.
  493. * Good: "Fixed Unicode bug in RSS API."
  494. * Bad: "Fixes Unicode bug in RSS API."
  495. * Bad: "Fixing Unicode bug in RSS API."
  496. * For commits to a branch, prefix the commit message with the branch name.
  497. For example: "magic-removal: Added support for mind reading."
  498. * Limit commits to the most granular change that makes sense. This means,
  499. use frequent small commits rather than infrequent large commits. For
  500. example, if implementing feature X requires a small change to library Y,
  501. first commit the change to library Y, then commit feature X in a separate
  502. commit. This goes a *long way* in helping all core Django developers
  503. follow your changes.
  504. * Separate bug fixes from feature changes.
  505. Bug fixes need to be added to the current bugfix branch (e.g. the
  506. ``1.0.X`` branch) as well as the current trunk.
  507. * If your commit closes a ticket in the Django `ticket tracker`_, begin
  508. your commit message with the text "Fixed #abc", where "abc" is the number
  509. of the ticket your commit fixes. Example: "Fixed #123 -- Added support
  510. for foo". We've rigged Subversion and Trac so that any commit message
  511. in that format will automatically close the referenced ticket and post a
  512. comment to it with the full commit message.
  513. If your commit closes a ticket and is in a branch, use the branch name
  514. first, then the "Fixed #abc." For example:
  515. "magic-removal: Fixed #123 -- Added whizbang feature."
  516. For the curious: We're using a `Trac post-commit hook`_ for this.
  517. .. _Trac post-commit hook: http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook
  518. * If your commit references a ticket in the Django `ticket tracker`_ but
  519. does *not* close the ticket, include the phrase "Refs #abc", where "abc"
  520. is the number of the ticket your commit references. We've rigged
  521. Subversion and Trac so that any commit message in that format will
  522. automatically post a comment to the appropriate ticket.
  523. Unit tests
  524. ==========
  525. Django comes with a test suite of its own, in the ``tests`` directory of the
  526. Django tarball. It's our policy to make sure all tests pass at all times.
  527. The tests cover:
  528. * Models and the database API (``tests/modeltests/``).
  529. * Everything else in core Django code (``tests/regressiontests``)
  530. * Contrib apps (``django/contrib/<contribapp>/tests``, see below)
  531. We appreciate any and all contributions to the test suite!
  532. The Django tests all use the testing infrastructure that ships with Django for
  533. testing applications. See :ref:`Testing Django applications <topics-testing>`
  534. for an explanation of how to write new tests.
  535. Running the unit tests
  536. ----------------------
  537. To run the tests, ``cd`` to the ``tests/`` directory and type:
  538. .. code-block:: bash
  539. ./runtests.py --settings=path.to.django.settings
  540. Yes, the unit tests need a settings module, but only for database connection
  541. info, with the ``DATABASE_ENGINE`` setting.
  542. If you're using the ``sqlite3`` database backend, no further settings are
  543. needed. A temporary database will be created in memory when running the tests.
  544. If you're using another backend:
  545. * Your :setting:`DATABASE_USER` setting needs to specify an existing user account
  546. for the database engine.
  547. * The :setting:`DATABASE_NAME` setting must be the name of an existing database to
  548. which the given user has permission to connect. The unit tests will not
  549. touch this database; the test runner creates a new database whose name is
  550. :setting:`DATABASE_NAME` prefixed with ``test_``, and this test database is
  551. deleted when the tests are finished. This means your user account needs
  552. permission to execute ``CREATE DATABASE``.
  553. You will also need to ensure that your database uses UTF-8 as the default
  554. character set. If your database server doesn't use UTF-8 as a default charset,
  555. you will need to include a value for ``TEST_DATABASE_CHARSET`` in your settings
  556. file.
  557. If you want to run the full suite of tests, you'll need to install a number of
  558. dependencies:
  559. * PyYAML_
  560. * Markdown_
  561. * Textile_
  562. * Docutils_
  563. * setuptools_
  564. Each of these dependencies is optional. If you're missing any of them, the
  565. associated tests will be skipped.
  566. .. _PyYAML: http://pyyaml.org/wiki/PyYAML
  567. .. _Markdown: http://pypi.python.org/pypi/Markdown/1.7
  568. .. _Textile: http://pypi.python.org/pypi/textile
  569. .. _docutils: http://pypi.python.org/pypi/docutils/0.4
  570. .. _setuptools: http://pypi.python.org/pypi/setuptools/
  571. To run a subset of the unit tests, append the names of the test modules to the
  572. ``runtests.py`` command line. See the list of directories in
  573. ``tests/modeltests`` and ``tests/regressiontests`` for module names.
  574. As an example, if Django is not in your ``PYTHONPATH``, you placed
  575. ``settings.py`` in the ``tests/`` directory, and you'd like to only run tests
  576. for generic relations and internationalization, type:
  577. .. code-block:: bash
  578. PYTHONPATH=..
  579. ./runtests.py --settings=settings generic_relations i18n
  580. Contrib apps
  581. ------------
  582. Tests for apps in ``django/contrib/`` go in their respective directories under
  583. ``django/contrib/``, in a ``tests.py`` file. (You can split the tests over
  584. multiple modules by using a ``tests`` directory in the normal Python way.)
  585. For the tests to be found, a ``models.py`` file must exist (it doesn't
  586. have to have anything in it). If you have URLs that need to be
  587. mapped, put them in ``tests/urls.py``.
  588. To run tests for just one contrib app (e.g. ``markup``), use the same
  589. method as above::
  590. ./runtests.py --settings=settings markup
  591. Requesting features
  592. ===================
  593. We're always trying to make Django better, and your feature requests are a key
  594. part of that. Here are some tips on how to most effectively make a request:
  595. * Request the feature on `django-developers`_, not in the ticket tracker;
  596. it'll get read more closely if it's on the mailing list.
  597. * Describe clearly and concisely what the missing feature is and how you'd
  598. like to see it implemented. Include example code (non-functional is OK)
  599. if possible.
  600. * Explain *why* you'd like the feature. In some cases this is obvious, but
  601. since Django is designed to help real developers get real work done,
  602. you'll need to explain it, if it isn't obvious why the feature would be
  603. useful.
  604. As with most open-source projects, code talks. If you are willing to write the
  605. code for the feature yourself or if (even better) you've already written it,
  606. it's much more likely to be accepted. If it's a large feature that might need
  607. multiple developers we're always happy to give you an experimental branch in
  608. our repository; see below.
  609. Branch policy
  610. =============
  611. In general, the trunk must be kept stable. People should be able to run
  612. production sites against the trunk at any time. Additionally, commits to trunk
  613. ought to be as atomic as possible -- smaller changes are better. Thus, large
  614. feature changes -- that is, changes too large to be encapsulated in a single
  615. patch, or changes that need multiple eyes on them -- must happen on dedicated
  616. branches.
  617. This means that if you want to work on a large feature -- anything that would
  618. take more than a single patch, or requires large-scale refactoring -- you need
  619. to do it on a feature branch. Our development process recognizes two options
  620. for feature branches:
  621. 1. Feature branches using a distributed revision control system like
  622. Git_, Mercurial_, Bazaar_, etc.
  623. If you're familiar with one of these tools, this is probably your best
  624. option since it doesn't require any support or buy-in from the Django
  625. core developers.
  626. However, do keep in mind that Django will continue to use Subversion for
  627. the foreseeable future, and this will naturally limit the recognition of
  628. your branch. Further, if your branch becomes eligible for merging to
  629. trunk you'll need to find a core developer familiar with your DVCS of
  630. choice who'll actually perform the merge.
  631. If you do decided to start a distributed branch of Django and choose to make it
  632. public, please add the branch to the `Django branches`_ wiki page.
  633. 2. Feature branches using SVN have a higher bar. If you want a branch in SVN
  634. itself, you'll need a "mentor" among the :ref:`core committers
  635. <internals-committers>`. This person is responsible for actually creating
  636. the branch, monitoring your process (see below), and ultimately merging
  637. the branch into trunk.
  638. If you want a feature branch in SVN, you'll need to ask in
  639. `django-developers`_ for a mentor.
  640. .. _git: http://git.or.cz/
  641. .. _mercurial: http://www.selenic.com/mercurial/
  642. .. _bazaar: http://bazaar-vcs.org/
  643. .. _django branches: http://code.djangoproject.com/wiki/DjangoBranches
  644. Branch rules
  645. ------------
  646. We've got a few rules for branches born out of experience with what makes a
  647. successful Django branch.
  648. DVCS branches are obviously not under central control, so we have no way of
  649. enforcing these rules. However, if you're using a DVCS, following these rules
  650. will give you the best chance of having a successful branch (read: merged back to
  651. trunk).
  652. Developers with branches in SVN, however, **must** follow these rules. The
  653. branch mentor will keep on eye on the branch and **will delete it** if these
  654. rules are broken.
  655. * Only branch entire copies of the Django tree, even if work is only
  656. happening on part of that tree. This makes it painless to switch to a
  657. branch.
  658. * Merge changes from trunk no less than once a week, and preferably every
  659. couple-three days.
  660. In our experience, doing regular trunk merges is often the difference
  661. between a successful branch and one that fizzles and dies.
  662. If you're working on an SVN branch, you should be using `svnmerge.py`_
  663. to track merges from trunk.
  664. * Keep tests passing and documentation up-to-date. As with patches,
  665. we'll only merge a branch that comes with tests and documentation.
  666. .. _svnmerge.py: http://www.orcaware.com/svn/wiki/Svnmerge.py
  667. Once the branch is stable and ready to be merged into the trunk, alert
  668. `django-developers`_.
  669. After a branch has been merged, it should be considered "dead"; write access to
  670. it will be disabled, and old branches will be periodically "trimmed." To keep
  671. our SVN wrangling to a minimum, we won't be merging from a given branch into the
  672. trunk more than once.
  673. Using branches
  674. --------------
  675. To use a branch, you'll need to do two things:
  676. * Get the branch's code through Subversion.
  677. * Point your Python ``site-packages`` directory at the branch's version of
  678. the ``django`` package rather than the version you already have
  679. installed.
  680. Getting the code from Subversion
  681. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  682. To get the latest version of a branch's code, check it out using Subversion:
  683. .. code-block:: bash
  684. svn co http://code.djangoproject.com/svn/django/branches/<branch>/
  685. ...where ``<branch>`` is the branch's name. See the `list of branch names`_.
  686. Alternatively, you can automatically convert an existing directory of the
  687. Django source code as long as you've checked it out via Subversion. To do the
  688. conversion, execute this command from within your ``django`` directory:
  689. .. code-block:: bash
  690. svn switch http://code.djangoproject.com/svn/django/branches/<branch>/
  691. The advantage of using ``svn switch`` instead of ``svn co`` is that the
  692. ``switch`` command retains any changes you might have made to your local copy
  693. of the code. It attempts to merge those changes into the "switched" code. The
  694. disadvantage is that it may cause conflicts with your local changes if the
  695. "switched" code has altered the same lines of code.
  696. (Note that if you use ``svn switch``, you don't need to point Python at the new
  697. version, as explained in the next section.)
  698. .. _list of branch names: http://code.djangoproject.com/browser/django/branches
  699. Pointing Python at the new Django version
  700. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  701. Once you've retrieved the branch's code, you'll need to change your Python
  702. ``site-packages`` directory so that it points to the branch version of the
  703. ``django`` directory. (The ``site-packages`` directory is somewhere such as
  704. ``/usr/lib/python2.4/site-packages`` or
  705. ``/usr/local/lib/python2.4/site-packages`` or ``C:\Python\site-packages``.)
  706. The simplest way to do this is by renaming the old ``django`` directory to
  707. ``django.OLD`` and moving the trunk version of the code into the directory
  708. and calling it ``django``.
  709. Alternatively, you can use a symlink called ``django`` that points to the
  710. location of the branch's ``django`` package. If you want to switch back, just
  711. change the symlink to point to the old code.
  712. A third option is to use a `path file`_ (``<something>.pth``) which should
  713. work on all systems (including Windows, which doesn't have symlinks
  714. available). First, make sure there are no files, directories or symlinks named
  715. ``django`` in your ``site-packages`` directory. Then create a text file named
  716. ``django.pth`` and save it to your ``site-packages`` directory. That file
  717. should contain a path to your copy of Django on a single line and optional
  718. comments. Here is an example that points to multiple branches. Just uncomment
  719. the line for the branch you want to use ('Trunk' in this example) and make
  720. sure all other lines are commented::
  721. # Trunk is a svn checkout of:
  722. # http://code.djangoproject.com/svn/django/trunk/
  723. #
  724. /path/to/trunk
  725. # <branch> is a svn checkout of:
  726. # http://code.djangoproject.com/svn/django/branches/<branch>/
  727. #
  728. #/path/to/<branch>
  729. # On windows a path may look like this:
  730. # C:/path/to/<branch>
  731. If you're using Django 0.95 or earlier and installed it using
  732. ``python setup.py install``, you'll have a directory called something like
  733. ``Django-0.95-py2.4.egg`` instead of ``django``. In this case, edit the file
  734. ``setuptools.pth`` and remove the line that references the Django ``.egg``
  735. file. Then copy the branch's version of the ``django`` directory into
  736. ``site-packages``.
  737. .. _path file: http://docs.python.org/lib/module-site.html
  738. Deciding on features
  739. ====================
  740. Once a feature's been requested and discussed, eventually we'll have a decision
  741. about whether to include the feature or drop it.
  742. Whenever possible, we strive for a rough consensus. To that end, we'll often
  743. have informal votes on `django-developers`_ about a feature. In these votes we
  744. follow the voting style invented by Apache and used on Python itself, where
  745. votes are given as +1, +0, -0, or -1. Roughly translated, these votes mean:
  746. * +1: "I love the idea and I'm strongly committed to it."
  747. * +0: "Sounds OK to me."
  748. * -0: "I'm not thrilled, but I won't stand in the way."
  749. * -1: "I strongly disagree and would be very unhappy to see the idea turn
  750. into reality."
  751. Although these votes on django-developers are informal, they'll be taken very
  752. seriously. After a suitable voting period, if an obvious consensus arises
  753. we'll follow the votes.
  754. However, consensus is not always possible. Tough decisions will be discussed by
  755. all full committers and finally decided by the Benevolent Dictators for Life,
  756. Adrian and Jacob.
  757. Commit access
  758. =============
  759. Django has two types of committers:
  760. Full committers
  761. These are people who have a long history of contributions to Django's
  762. codebase, a solid track record of being polite and helpful on the mailing
  763. lists, and a proven desire to dedicate serious time to Django's development.
  764. The bar is very high for full commit access. It will only be granted by
  765. unanimous approval of all existing full committers, and the decision will err
  766. on the side of rejection.
  767. Partial committers
  768. These are people who are "domain experts." They have direct check-in access
  769. to the subsystems that fall under their jurisdiction, and they're given a
  770. formal vote in questions that involve their subsystems. This type of access
  771. is likely to be given to someone who contributes a large subframework to
  772. Django and wants to continue to maintain it.
  773. Like full committers, partial commit access is by unanimous approval of all
  774. full committers (and any other partial committers in the same area).
  775. However, the bar is set lower; proven expertise in the area in question is
  776. likely to be sufficient.
  777. To request commit access, please contact an existing committer privately. Public
  778. requests for commit access are potential flame-war starters, and will be ignored.
  779. .. _community page: http://www.djangoproject.com/community/
  780. .. _ticket tracker: http://code.djangoproject.com/newticket
  781. .. _django-developers: http://groups.google.com/group/django-developers
  782. .. _search the tracker: http://code.djangoproject.com/search
  783. .. _django-users: http://groups.google.com/group/django-users
  784. .. _`#django`: irc://irc.freenode.net/django
  785. .. _list of tickets with patches: http://code.djangoproject.com/query?status=new&status=assigned&status=reopened&has_patch=1&order=priority
  786. .. _pep8.py: http://svn.browsershots.org/trunk/devtools/pep8/pep8.py
  787. .. _i18n branch: http://code.djangoproject.com/browser/django/branches/i18n
  788. .. _`tags/releases`: http://code.djangoproject.com/browser/django/tags/releases