faq.txt 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. ==========
  2. Django FAQ
  3. ==========
  4. General questions
  5. =================
  6. Why does this project exist?
  7. ----------------------------
  8. Django grew from a very practical need: World Online, a newspaper Web
  9. operation, is responsible for building intensive Web applications on journalism
  10. deadlines. In the fast-paced newsroom, World Online often has only a matter of
  11. hours to take a complicated Web application from concept to public launch.
  12. At the same time, the World Online Web developers have consistently been
  13. perfectionists when it comes to following best practices of Web development.
  14. In fall 2003, the World Online developers (Adrian Holovaty and Simon Willison)
  15. ditched PHP and began using Python to develop its Web sites. As they built
  16. intensive, richly interactive sites such as Lawrence.com, they began to extract
  17. a generic Web development framework that let them build Web applications more
  18. and more quickly. They tweaked this framework constantly, adding improvements
  19. over two years.
  20. In summer 2005, World Online decided to open-source the resulting software,
  21. Django. Django would not be possible without a whole host of open-source
  22. projects -- `Apache`_, `Python`_, and `PostgreSQL`_ to name a few -- and we're
  23. thrilled to be able to give something back to the open-source community.
  24. .. _Apache: http://httpd.apache.org/
  25. .. _Python: http://www.python.org/
  26. .. _PostgreSQL: http://www.postgresql.org/
  27. What does "Django" mean, and how do you pronounce it?
  28. -----------------------------------------------------
  29. Django is named after `Django Reinhardt`_, a gypsy jazz guitarist from the 1930s
  30. to early 1950s. To this day, he's considered one of the best guitarists of all time.
  31. Listen to his music. You'll like it.
  32. Django is pronounced **JANG**-oh. Rhymes with FANG-oh. The "D" is silent.
  33. We've also recorded an `audio clip of the pronunciation`_.
  34. .. _Django Reinhardt: http://en.wikipedia.org/wiki/Django_Reinhardt
  35. .. _audio clip of the pronunciation: http://red-bean.com/~adrian/django_pronunciation.mp3
  36. Is Django stable?
  37. -----------------
  38. Yes. World Online has been using Django for more than three years. Sites built
  39. on Django have weathered traffic spikes of over one million hits an hour and a
  40. number of Slashdottings. Yes, it's quite stable.
  41. Does Django scale?
  42. ------------------
  43. Yes. Compared to development time, hardware is cheap, and so Django is
  44. designed to take advantage of as much hardware as you can throw at it.
  45. Django uses a "shared-nothing" architecture, which means you can add hardware
  46. at any level -- database servers, caching servers or Web/application servers.
  47. The framework cleanly separates components such as its database layer and
  48. application layer. And it ships with a simple-yet-powerful `cache framework`_.
  49. .. _`cache framework`: ../cache/
  50. Who's behind this?
  51. ------------------
  52. Django was developed at `World Online`_, the Web department of a newspaper in
  53. Lawrence, Kansas, USA.
  54. `Adrian Holovaty`_
  55. Adrian is a Web developer with a background in journalism. He was lead
  56. developer at World Online for 2.5 years, during which time Django was
  57. developed and implemented on World Online's sites. Now he works for
  58. washingtonpost.com building rich, database-backed information sites, and
  59. continues to oversee Django development. He likes playing guitar (Django
  60. Reinhardt style) and hacking on side projects such as `chicagocrime.org`_.
  61. He lives in Chicago.
  62. On IRC, Adrian goes by ``adrian_h``.
  63. `Jacob Kaplan-Moss`_
  64. Jacob is a whipper-snapper from California who spends equal time coding and
  65. cooking. He's lead developer at World Online and actively hacks on various
  66. cool side projects. He's contributed to the Python-ObjC bindings and was
  67. the first guy to figure out how to write Tivo apps in Python. Lately he's
  68. been messing with Python on the PSP. He lives in Lawrence, Kansas.
  69. On IRC, Jacob goes by ``jacobkm``.
  70. `Simon Willison`_
  71. Simon is a well-respected Web developer from England. He had a one-year
  72. internship at World Online, during which time he and Adrian developed
  73. Django from scratch. The most enthusiastic Brit you'll ever meet, he's
  74. passionate about best practices in Web development and has maintained a
  75. well-read Web-development blog for years at http://simon.incutio.com.
  76. He works for Yahoo UK, where he managed to score the title "Hacker Liason."
  77. He lives in London.
  78. On IRC, Simon goes by ``SimonW``.
  79. `Wilson Miner`_
  80. Wilson's design-fu makes us all look like rock stars. By day, he's an
  81. interactive designer for `Apple`_. Don't ask him what he's working on, or
  82. he'll have to kill you. He lives in San Francisco.
  83. On IRC, Wilson goes by ``wilsonian``.
  84. .. _`World Online`: http://code.djangoproject.com/wiki/WorldOnline
  85. .. _`Adrian Holovaty`: http://www.holovaty.com/
  86. .. _`washingtonpost.com`: http://www.washingtonpost.com/
  87. .. _`chicagocrime.org`: http://www.chicagocrime.org/
  88. .. _`Simon Willison`: http://simon.incutio.com/
  89. .. _`simon.incutio.com`: http://simon.incutio.com/
  90. .. _`Jacob Kaplan-Moss`: http://www.jacobian.org/
  91. .. _`Wilson Miner`: http://www.wilsonminer.com/
  92. .. _`Apple`: http://www.apple.com/
  93. Which sites use Django?
  94. -----------------------
  95. The Django wiki features a consistently growing `list of Django-powered sites`_.
  96. Feel free to add your Django-powered site to the list.
  97. .. _list of Django-powered sites: http://code.djangoproject.com/wiki/DjangoPoweredSites
  98. Django appears to be a MVC framework, but you call the Controller the "view", and the View the "template". How come you don't use the standard names?
  99. -----------------------------------------------------------------------------------------------------------------------------------------------------
  100. Well, the standard names are debatable.
  101. In our interpretation of MVC, the "view" describes the data that gets presented
  102. to the user. It's not necessarily *how* the data *looks*, but *which* data is
  103. presented. The view describes *which data you see*, not *how you see it.* It's
  104. a subtle distinction.
  105. So, in our case, a "view" is the Python callback function for a particular URL,
  106. because that callback function describes which data is presented.
  107. Furthermore, it's sensible to separate content from presentation -- which is
  108. where templates come in. In Django, a "view" describes which data is presented,
  109. but a view normally delegates to a template, which describes *how* the data is
  110. presented.
  111. Where does the "controller" fit in, then? In Django's case, it's probably the
  112. framework itself: the machinery that sends a request to the appropriate view,
  113. according to the Django URL configuration.
  114. If you're hungry for acronyms, you might say that Django is a "MTV" framework
  115. -- that is, "model", "template", and "view." That breakdown makes much more
  116. sense.
  117. At the end of the day, of course, it comes down to getting stuff done. And,
  118. regardless of how things are named, Django gets stuff done in a way that's most
  119. logical to us.
  120. <Framework X> does <feature Y> -- why doesn't Django?
  121. -----------------------------------------------------
  122. We're well aware that there are other awesome Web frameworks out there, and
  123. we're not averse to borrowing ideas where appropriate. However, Django was
  124. developed precisely because we were unhappy with the status quo, so please be
  125. aware that "because <Framework X> does it" is not going to be sufficient reason
  126. to add a given feature to Django.
  127. Why did you write all of Django from scratch, instead of using other Python libraries?
  128. --------------------------------------------------------------------------------------
  129. When Django was originally written a couple of years ago, Adrian and Simon
  130. spent quite a bit of time exploring the various Python Web frameworks
  131. available.
  132. In our opinion, none of them were completely up to snuff.
  133. We're picky. You might even call us perfectionists. (With deadlines.)
  134. Over time, we stumbled across open-source libraries that did things we'd
  135. already implemented. It was reassuring to see other people solving similar
  136. problems in similar ways, but it was too late to integrate outside code: We'd
  137. already written, tested and implemented our own framework bits in several
  138. production settings -- and our own code met our needs delightfully.
  139. In most cases, however, we found that existing frameworks/tools inevitably had
  140. some sort of fundamental, fatal flaw that made us squeamish. No tool fit our
  141. philosophies 100%.
  142. Like we said: We're picky.
  143. We've documented our philosophies on the `design philosophies page`_.
  144. .. _design philosophies page: ../design_philosophies/
  145. Do you have any of those nifty "screencast" things?
  146. ---------------------------------------------------
  147. You can bet your bottom they're on the way. But, since we're still hammering
  148. out a few points, we want to make sure they reflect the final state of things
  149. at Django 1.0, not some intermediary step. In other words, we don't want to
  150. spend a lot of energy creating screencasts yet, because Django APIs will shift.
  151. Is Django a content-management-system (CMS)?
  152. --------------------------------------------
  153. No, Django is not a CMS, or any sort of "turnkey product" in and of itself.
  154. It's a Web framework; it's a programming tool that lets you build Web sites.
  155. For example, it doesn't make much sense to compare Django to something like
  156. Drupal_, because Django is something you use to *create* things like Drupal.
  157. Of course, Django's automatic admin site is fantastic and timesaving -- but
  158. the admin site is one module of Django the framework. Furthermore, although
  159. Django has special conveniences for building "CMS-y" apps, that doesn't mean
  160. it's not just as appropriate for building "non-CMS-y" apps (whatever that
  161. means!).
  162. .. _Drupal: http://drupal.org/
  163. When will you release Django 1.0?
  164. ---------------------------------
  165. See our `version one roadmap`_ for the detailed timeline. We're aiming for
  166. September 2, 2008.
  167. .. _version one roadmap: http://code.djangoproject.com/wiki/VersionOneRoadmap
  168. How can I download the Django documentation to read it offline?
  169. ---------------------------------------------------------------
  170. The Django docs are available in the ``docs`` directory of each Django tarball
  171. release. These docs are in ReST (ReStructured Text) format, and each text file
  172. corresponds to a Web page on the official Django site.
  173. Because the documentation is `stored in revision control`_, you can browse
  174. documentation changes just like you can browse code changes.
  175. Technically, the docs on Django's site are generated from the latest development
  176. versions of those ReST documents, so the docs on the Django site may offer more
  177. information than the docs that come with the latest Django release.
  178. .. _stored in revision control: http://code.djangoproject.com/browser/django/trunk/docs
  179. Where can I find Django developers for hire?
  180. --------------------------------------------
  181. Consult our `developers for hire page`_ for a list of Django developers who
  182. would be happy to help you.
  183. You might also be interested in posting a job to http://djangogigs.com/ .
  184. If you want to find Django-capable people in your local area, try
  185. http://djangopeople.net/ .
  186. .. _developers for hire page: http://code.djangoproject.com/wiki/DevelopersForHire
  187. Installation questions
  188. ======================
  189. How do I get started?
  190. ---------------------
  191. #. `Download the code`_.
  192. #. Install Django (read the `installation guide`_).
  193. #. Walk through the tutorial_.
  194. #. Check out the rest of the documentation_, and `ask questions`_ if you
  195. run into trouble.
  196. .. _`Download the code`: http://www.djangoproject.com/download/
  197. .. _`installation guide`: ../install/
  198. .. _tutorial: ../tutorial01/
  199. .. _documentation: ../
  200. .. _ask questions: http://www.djangoproject.com/community/
  201. How do I fix the "install a later version of setuptools" error?
  202. ---------------------------------------------------------------
  203. Just run the ``ez_setup.py`` script in the Django distribution.
  204. What are Django's prerequisites?
  205. --------------------------------
  206. Django requires Python_ 2.3 or later. No other Python libraries are required
  207. for basic Django usage.
  208. For a development environment -- if you just want to experiment with Django --
  209. you don't need to have a separate Web server installed; Django comes with its
  210. own lightweight development server. For a production environment, we recommend
  211. `Apache 2`_ and mod_python_, although Django follows the WSGI_ spec, which
  212. means it can run on a variety of server platforms.
  213. If you want to use Django with a database, which is probably the case, you'll
  214. also need a database engine. PostgreSQL_ is recommended, because we're
  215. PostgreSQL fans, and MySQL_, `SQLite 3`_, and Oracle_ are also supported.
  216. .. _Python: http://www.python.org/
  217. .. _Apache 2: http://httpd.apache.org/
  218. .. _mod_python: http://www.modpython.org/
  219. .. _WSGI: http://www.python.org/peps/pep-0333.html
  220. .. _PostgreSQL: http://www.postgresql.org/
  221. .. _MySQL: http://www.mysql.com/
  222. .. _`SQLite 3`: http://www.sqlite.org/
  223. .. _Oracle: http://www.oracle.com/
  224. Do I lose anything by using Python 2.3 versus newer Python versions, such as Python 2.5?
  225. ----------------------------------------------------------------------------------------
  226. No. Django itself is guaranteed to work with any version of Python from 2.3
  227. and higher.
  228. If you use a Python version newer than 2.3, you will, of course, be able to
  229. take advantage of newer Python features in your own code, along with the speed
  230. improvements and other optimizations that have been made to the Python language
  231. itself. But the Django framework itself should work equally well on 2.3 as it
  232. does on 2.4 or 2.5.
  233. Do I have to use mod_python?
  234. ----------------------------
  235. Although we recommend mod_python for production use, you don't have to use it,
  236. thanks to the fact that Django uses an arrangement called WSGI_. Django can
  237. talk to any WSGI-enabled server. Other non-mod_python deployment setups are
  238. FastCGI, SCGI or AJP. See `How to use Django with FastCGI, SCGI or AJP`_ for
  239. full information.
  240. Also, see the `server arrangements wiki page`_ for other deployment strategies.
  241. If you just want to play around and develop things on your local computer, use
  242. the development Web server that comes with Django. Things should Just Work.
  243. .. _WSGI: http://www.python.org/peps/pep-0333.html
  244. .. _How to use Django with FastCGI, SCGI or AJP: ../fastcgi/
  245. .. _server arrangements wiki page: http://code.djangoproject.com/wiki/ServerArrangements
  246. How do I install mod_python on Windows?
  247. ---------------------------------------
  248. * For Python 2.4, grab mod_python from `win32 build of mod_python for
  249. Python 2.4`_.
  250. * For Python 2.4, check out this `Django on Windows howto`_.
  251. * For Python 2.3, grab mod_python from http://www.modpython.org/ and read
  252. `Running mod_python on Apache on Windows2000`_.
  253. * Also, try this (not Windows-specific) `guide to getting mod_python
  254. working`_.
  255. .. _`win32 build of mod_python for Python 2.4`: http://www.lehuen.com/nicolas/index.php/2005/02/21/39-win32-build-of-mod_python-314-for-python-24
  256. .. _`Django on Windows howto`: http://thinkhole.org/wp/django-on-windows/
  257. .. _`Running mod_python on Apache on Windows2000`: http://groups-beta.google.com/group/comp.lang.python/msg/139af8c83a5a9d4f
  258. .. _`guide to getting mod_python working`: http://www.dscpl.com.au/articles/modpython-001.html
  259. Will Django run under shared hosting (like TextDrive or Dreamhost)?
  260. -------------------------------------------------------------------
  261. See our `Django-friendly Web hosts`_ page.
  262. .. _`Django-friendly Web hosts`: http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts
  263. Should I use the official version or development version?
  264. ---------------------------------------------------------
  265. The Django developers improve Django every day and are pretty good about not
  266. checking in broken code. We use the development code (from the Subversion
  267. repository) directly on our servers, so we consider it stable. With that in
  268. mind, we recommend that you use the latest development code, because it
  269. generally contains more features and fewer bugs than the "official" releases.
  270. Using Django
  271. ============
  272. Why do I get an error about importing DJANGO_SETTINGS_MODULE?
  273. -------------------------------------------------------------
  274. Make sure that:
  275. * The environment variable DJANGO_SETTINGS_MODULE is set to a fully-qualified
  276. Python module (i.e. "mysite.settings").
  277. * Said module is on ``sys.path`` (``import mysite.settings`` should work).
  278. * The module doesn't contain syntax errors (of course).
  279. * If you're using mod_python but *not* using Django's request handler,
  280. you'll need to work around a mod_python bug related to the use of
  281. ``SetEnv``; before you import anything from Django you'll need to do
  282. the following::
  283. os.environ.update(req.subprocess_env)
  284. (where ``req`` is the mod_python request object).
  285. I can't stand your template language. Do I have to use it?
  286. ----------------------------------------------------------
  287. We happen to think our template engine is the best thing since chunky bacon,
  288. but we recognize that choosing a template language runs close to religion.
  289. There's nothing about Django that requires using the template language, so
  290. if you're attached to ZPT, Cheetah, or whatever, feel free to use those.
  291. Do I have to use your model/database layer?
  292. -------------------------------------------
  293. Nope. Just like the template system, the model/database layer is decoupled from
  294. the rest of the framework.
  295. The one exception is: If you use a different database library, you won't get to
  296. use Django's automatically-generated admin site. That app is coupled to the
  297. Django database layer.
  298. How do I use image and file fields?
  299. -----------------------------------
  300. Using a ``FileField`` or an ``ImageField`` in a model takes a few steps:
  301. #. In your settings file, define ``MEDIA_ROOT`` as the full path to
  302. a directory where you'd like Django to store uploaded files. (For
  303. performance, these files are not stored in the database.) Define
  304. ``MEDIA_URL`` as the base public URL of that directory. Make sure that
  305. this directory is writable by the Web server's user account.
  306. #. Add the ``FileField`` or ``ImageField`` to your model, making sure
  307. to define the ``upload_to`` option to tell Django to which subdirectory
  308. of ``MEDIA_ROOT`` it should upload files.
  309. #. All that will be stored in your database is a path to the file
  310. (relative to ``MEDIA_ROOT``). You'll most likely want to use the
  311. convenience ``get_<fieldname>_url`` function provided by Django. For
  312. example, if your ``ImageField`` is called ``mug_shot``, you can get the
  313. absolute URL to your image in a template with
  314. ``{{ object.get_mug_shot_url }}``.
  315. Databases and models
  316. ====================
  317. How can I see the raw SQL queries Django is running?
  318. ----------------------------------------------------
  319. Make sure your Django ``DEBUG`` setting is set to ``True``. Then, just do
  320. this::
  321. >>> from django.db import connection
  322. >>> connection.queries
  323. [{'sql': 'SELECT polls_polls.id,polls_polls.question,polls_polls.pub_date FROM polls_polls',
  324. 'time': '0.002'}]
  325. ``connection.queries`` is only available if ``DEBUG`` is ``True``. It's a list
  326. of dictionaries in order of query execution. Each dictionary has the following::
  327. ``sql`` -- The raw SQL statement
  328. ``time`` -- How long the statement took to execute, in seconds.
  329. ``connection.queries`` includes all SQL statements -- INSERTs, UPDATES,
  330. SELECTs, etc. Each time your app hits the database, the query will be recorded.
  331. Can I use Django with a pre-existing database?
  332. ----------------------------------------------
  333. Yes. See `Integrating with a legacy database`_.
  334. .. _`Integrating with a legacy database`: ../legacy_databases/
  335. If I make changes to a model, how do I update the database?
  336. -----------------------------------------------------------
  337. If you don't mind clearing data, your project's ``manage.py`` utility has an
  338. option to reset the SQL for a particular application::
  339. manage.py reset appname
  340. This drops any tables associated with ``appname`` and recreates them.
  341. If you do care about deleting data, you'll have to execute the ``ALTER TABLE``
  342. statements manually in your database. That's the way we've always done it,
  343. because dealing with data is a very sensitive operation that we've wanted to
  344. avoid automating. That said, there's some work being done to add partially
  345. automated database-upgrade functionality.
  346. Do Django models support multiple-column primary keys?
  347. ------------------------------------------------------
  348. No. Only single-column primary keys are supported.
  349. But this isn't an issue in practice, because there's nothing stopping you from
  350. adding other constraints (using the ``unique_together`` model option or
  351. creating the constraint directly in your database), and enforcing the
  352. uniqueness at that level. Single-column primary keys are needed for things such
  353. as the admin interface to work; e.g., you need a simple way of being able to
  354. specify an object to edit or delete.
  355. How do I add database-specific options to my CREATE TABLE statements, such as specifying MyISAM as the table type?
  356. ------------------------------------------------------------------------------------------------------------------
  357. We try to avoid adding special cases in the Django code to accommodate all the
  358. database-specific options such as table type, etc. If you'd like to use any of
  359. these options, create an `SQL initial data file`_ that contains ``ALTER TABLE``
  360. statements that do what you want to do. The initial data files are executed in
  361. your database after the ``CREATE TABLE`` statements.
  362. For example, if you're using MySQL and want your tables to use the MyISAM table
  363. type, create an initial data file and put something like this in it::
  364. ALTER TABLE myapp_mytable ENGINE=MyISAM;
  365. As explained in the `SQL initial data file`_ documentation, this SQL file can
  366. contain arbitrary SQL, so you can make any sorts of changes you need to make.
  367. .. _SQL initial data file: ../model-api/#providing-initial-sql-data
  368. Why is Django leaking memory?
  369. -----------------------------
  370. Django isn't known to leak memory. If you find your Django processes are
  371. allocating more and more memory, with no sign of releasing it, check to make
  372. sure your ``DEBUG`` setting is set to ``True``. If ``DEBUG`` is ``True``, then
  373. Django saves a copy of every SQL statement it has executed.
  374. (The queries are saved in ``django.db.connection.queries``. See
  375. `How can I see the raw SQL queries Django is running?`_.)
  376. To fix the problem, set ``DEBUG`` to ``False``.
  377. If you need to clear the query list manually at any point in your functions,
  378. just call ``reset_queries()``, like this::
  379. from django import db
  380. db.reset_queries()
  381. The admin site
  382. ==============
  383. I can't log in. When I enter a valid username and password, it just brings up the login page again, with no error messages.
  384. ---------------------------------------------------------------------------------------------------------------------------
  385. The login cookie isn't being set correctly, because the domain of the cookie
  386. sent out by Django doesn't match the domain in your browser. Try these two
  387. things:
  388. * Set the ``SESSION_COOKIE_DOMAIN`` setting in your admin config file
  389. to match your domain. For example, if you're going to
  390. "http://www.mysite.com/admin/" in your browser, in
  391. "myproject.settings" you should set ``SESSION_COOKIE_DOMAIN = 'www.mysite.com'``.
  392. * Some browsers (Firefox?) don't like to accept cookies from domains that
  393. don't have dots in them. If you're running the admin site on "localhost"
  394. or another domain that doesn't have a dot in it, try going to
  395. "localhost.localdomain" or "127.0.0.1". And set
  396. ``SESSION_COOKIE_DOMAIN`` accordingly.
  397. I can't log in. When I enter a valid username and password, it brings up the login page again, with a "Please enter a correct username and password" error.
  398. -----------------------------------------------------------------------------------------------------------------------------------------------------------
  399. If you're sure your username and password are correct, make sure your user
  400. account has ``is_active`` and ``is_staff`` set to True. The admin site only
  401. allows access to users with those two fields both set to True.
  402. How can I prevent the cache middleware from caching the admin site?
  403. -------------------------------------------------------------------
  404. Set the ``CACHE_MIDDLEWARE_ANONYMOUS_ONLY`` setting to ``True``. See the
  405. `cache documentation`_ for more information.
  406. .. _cache documentation: ../cache/#the-per-site-cache
  407. How do I automatically set a field's value to the user who last edited the object in the admin?
  408. -----------------------------------------------------------------------------------------------
  409. At this point, Django doesn't have an official way to do this. But it's an oft-requested
  410. feature, so we're discussing how it can be implemented. The problem is we don't want to couple
  411. the model layer with the admin layer with the request layer (to get the current user). It's a
  412. tricky problem.
  413. One person hacked up a `solution that doesn't require patching Django`_, but note that it's an
  414. unofficial solution, and there's no guarantee it won't break at some point.
  415. .. _solution that doesn't require patching Django: http://lukeplant.me.uk/blog.php?id=1107301634
  416. How do I limit admin access so that objects can only be edited by the users who created them?
  417. ---------------------------------------------------------------------------------------------
  418. See the answer to the previous question.
  419. My admin-site CSS and images showed up fine using the development server, but they're not displaying when using mod_python.
  420. ---------------------------------------------------------------------------------------------------------------------------
  421. See `serving the admin files`_ in the "How to use Django with mod_python"
  422. documentation.
  423. .. _serving the admin files: ../modpython/#serving-the-admin-files
  424. My "list_filter" contains a ManyToManyField, but the filter doesn't display.
  425. ----------------------------------------------------------------------------
  426. Django won't bother displaying the filter for a ``ManyToManyField`` if there
  427. are fewer than two related objects.
  428. For example, if your ``list_filter`` includes ``sites``, and there's only one
  429. site in your database, it won't display a "Site" filter. In that case,
  430. filtering by site would be meaningless.
  431. How can I customize the functionality of the admin interface?
  432. -------------------------------------------------------------
  433. You've got several options. If you want to piggyback on top of an add/change
  434. form that Django automatically generates, you can attach arbitrary JavaScript
  435. modules to the page via the model's ``class Admin`` ``js`` parameter. That
  436. parameter is a list of URLs, as strings, pointing to JavaScript modules that
  437. will be included within the admin form via a ``<script>`` tag.
  438. If you want more flexibility than simply tweaking the auto-generated forms,
  439. feel free to write custom views for the admin. The admin is powered by Django
  440. itself, and you can write custom views that hook into the authentication
  441. system, check permissions and do whatever else they need to do.
  442. If you want to customize the look-and-feel of the admin interface, read the
  443. next question.
  444. The dynamically-generated admin site is ugly! How can I change it?
  445. ------------------------------------------------------------------
  446. We like it, but if you don't agree, you can modify the admin site's
  447. presentation by editing the CSS stylesheet and/or associated image files. The
  448. site is built using semantic HTML and plenty of CSS hooks, so any changes you'd
  449. like to make should be possible by editing the stylesheet. We've got a
  450. `guide to the CSS used in the admin`_ to get you started.
  451. .. _`guide to the CSS used in the admin`: ../admin_css/
  452. How do I create users without having to edit password hashes?
  453. -------------------------------------------------------------
  454. If you'd like to use the admin site to create users, upgrade to the Django
  455. development version, where this problem was fixed on Aug. 4, 2006.
  456. You can also use the Python API. See `creating users`_ for full info.
  457. .. _creating users: ../authentication/#creating-users
  458. Getting help
  459. ============
  460. How do I do X? Why doesn't Y work? Where can I go to get help?
  461. --------------------------------------------------------------
  462. If this FAQ doesn't contain an answer to your question, you might want to
  463. try the `django-users mailing list`_. Feel free to ask any question related
  464. to installing, using, or debugging Django.
  465. If you prefer IRC, the `#django IRC channel`_ on the Freenode IRC network is an
  466. active community of helpful individuals who may be able to solve your problem.
  467. .. _`django-users mailing list`: http://groups.google.com/group/django-users
  468. .. _`#django IRC channel`: irc://irc.freenode.net/django
  469. Why hasn't my message appeared on django-users?
  470. -----------------------------------------------
  471. django-users_ has a lot of subscribers. This is good for the community, as
  472. it means many people are available to contribute answers to questions.
  473. Unfortunately, it also means that django-users_ is an attractive target for
  474. spammers.
  475. In order to combat the spam problem, when you join the django-users_ mailing
  476. list, we manually moderate the first message you send to the list. This means
  477. that spammers get caught, but it also means that your first question to the
  478. list might take a little longer to get answered. We apologize for any
  479. inconvenience that this policy may cause.
  480. .. _django-users: http://groups.google.com/group/django-users
  481. Nobody on django-users answered my question! What should I do?
  482. --------------------------------------------------------------
  483. Try making your question more specific, or provide a better example of your
  484. problem.
  485. As with most open-source mailing lists, the folks on django-users_ are
  486. volunteers. If nobody has answered your question, it may be because nobody
  487. knows the answer, it may be because nobody can understand the question, or it
  488. may be that everybody that can help is busy. One thing you might try is to ask
  489. the question on IRC -- visit the `#django IRC channel`_ on the Freenode IRC
  490. network.
  491. You might notice we have a second mailing list, called django-developers_ --
  492. but please don't e-mail support questions to this mailing list. This list is
  493. for discussion of the development of Django itself. Asking a tech support
  494. question there is considered quite impolite.
  495. .. _django-developers: http://groups.google.com/group/django-developers
  496. I think I've found a bug! What should I do?
  497. -------------------------------------------
  498. Detailed instructions on how to handle a potential bug can be found in our
  499. `Guide to contributing to Django`_.
  500. .. _`Guide to contributing to Django`: ../contributing/#reporting-bugs
  501. I think I've found a security problem! What should I do?
  502. --------------------------------------------------------
  503. If you think you've found a security problem with Django, please send a message
  504. to security@djangoproject.com. This is a private list only open to long-time,
  505. highly trusted Django developers, and its archives are not publicly readable.
  506. Due to the sensitive nature of security issues, we ask that if you think you
  507. have found a security problem, *please* don't send a message to one of the
  508. public mailing lists. Django has a `policy for handling security issues`_;
  509. while a defect is outstanding, we would like to minimize any damage that
  510. could be inflicted through public knowledge of that defect.
  511. .. _`policy for handling security issues`: ../contributing/#reporting-security-issues
  512. Contributing code
  513. =================
  514. How can I get started contributing code to Django?
  515. --------------------------------------------------
  516. Thanks for asking! We've written an entire document devoted to this question.
  517. It's titled `Contributing to Django`_.
  518. .. _`Contributing to Django`: ../contributing/
  519. I submitted a bug fix in the ticket system several weeks ago. Why are you ignoring my patch?
  520. --------------------------------------------------------------------------------------------
  521. Don't worry: We're not ignoring you!
  522. It's important to understand there is a difference between "a ticket is being
  523. ignored" and "a ticket has not been attended to yet." Django's ticket system
  524. contains hundreds of open tickets, of various degrees of impact on end-user
  525. functionality, and Django's developers have to review and prioritize.
  526. On top of that: the people who work on Django are all volunteers. As a result,
  527. the amount of time that we have to work on the framework is limited and will
  528. vary from week to week depending on our spare time. If we're busy, we may not
  529. be able to spend as much time on Django as we might want.
  530. Besides, if your feature request stands no chance of inclusion in Django, we
  531. won't ignore it -- we'll just close the ticket. So if your ticket is still
  532. open, it doesn't mean we're ignoring you; it just means we haven't had time to
  533. look at it yet.