contributing.txt 42 KB

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