Changeset 4455 for django/branches/sqlalchemy/docs
- Timestamp:
- 01/31/07 17:43:09 (2 years ago)
- Files:
-
- django/branches/sqlalchemy/docs/add_ons.txt (modified) (8 diffs)
- django/branches/sqlalchemy/docs/apache_auth.txt (modified) (1 diff)
- django/branches/sqlalchemy/docs/api_stability.txt (modified) (1 diff)
- django/branches/sqlalchemy/docs/authentication.txt (modified) (8 diffs)
- django/branches/sqlalchemy/docs/cache.txt (modified) (1 diff)
- django/branches/sqlalchemy/docs/contributing.txt (modified) (7 diffs)
- django/branches/sqlalchemy/docs/csrf.txt (modified) (6 diffs)
- django/branches/sqlalchemy/docs/db-api.txt (modified) (3 diffs)
- django/branches/sqlalchemy/docs/design_philosophies.txt (modified) (1 diff)
- django/branches/sqlalchemy/docs/django-admin.txt (modified) (5 diffs)
- django/branches/sqlalchemy/docs/email.txt (modified) (2 diffs)
- django/branches/sqlalchemy/docs/faq.txt (modified) (10 diffs)
- django/branches/sqlalchemy/docs/fastcgi.txt (modified) (1 diff)
- django/branches/sqlalchemy/docs/flatpages.txt (modified) (3 diffs)
- django/branches/sqlalchemy/docs/forms.txt (modified) (3 diffs)
- django/branches/sqlalchemy/docs/generic_views.txt (modified) (16 diffs)
- django/branches/sqlalchemy/docs/i18n.txt (modified) (7 diffs)
- django/branches/sqlalchemy/docs/install.txt (modified) (3 diffs)
- django/branches/sqlalchemy/docs/legacy_databases.txt (modified) (3 diffs)
- django/branches/sqlalchemy/docs/middleware.txt (modified) (5 diffs)
- django/branches/sqlalchemy/docs/model-api.txt (modified) (4 diffs)
- django/branches/sqlalchemy/docs/modpython.txt (modified) (1 diff)
- django/branches/sqlalchemy/docs/newforms.txt (modified) (5 diffs)
- django/branches/sqlalchemy/docs/outputting_csv.txt (modified) (2 diffs)
- django/branches/sqlalchemy/docs/outputting_pdf.txt (modified) (1 diff)
- django/branches/sqlalchemy/docs/overview.txt (modified) (1 diff)
- django/branches/sqlalchemy/docs/redirects.txt (modified) (3 diffs)
- django/branches/sqlalchemy/docs/request_response.txt (modified) (2 diffs)
- django/branches/sqlalchemy/docs/sessions.txt (modified) (3 diffs)
- django/branches/sqlalchemy/docs/settings.txt (modified) (14 diffs)
- django/branches/sqlalchemy/docs/sitemaps.txt (modified) (6 diffs)
- django/branches/sqlalchemy/docs/sites.txt (modified) (2 diffs)
- django/branches/sqlalchemy/docs/static_files.txt (modified) (3 diffs)
- django/branches/sqlalchemy/docs/syndication_feeds.txt (modified) (5 diffs)
- django/branches/sqlalchemy/docs/templates_python.txt (modified) (6 diffs)
- django/branches/sqlalchemy/docs/templates.txt (modified) (3 diffs)
- django/branches/sqlalchemy/docs/testing.txt (modified) (4 diffs)
- django/branches/sqlalchemy/docs/tutorial01.txt (modified) (4 diffs)
- django/branches/sqlalchemy/docs/tutorial02.txt (modified) (4 diffs)
- django/branches/sqlalchemy/docs/tutorial03.txt (modified) (6 diffs)
- django/branches/sqlalchemy/docs/tutorial04.txt (modified) (3 diffs)
- django/branches/sqlalchemy/docs/url_dispatch.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/sqlalchemy/docs/add_ons.txt
r4186 r4455 18 18 `Tutorial 2`_. 19 19 20 .. _Tutorial 2: http://www.djangoproject.com/documentation/tutorial2/20 .. _Tutorial 2: ../tutorial2/ 21 21 22 22 auth … … 27 27 See the `authentication documentation`_. 28 28 29 .. _authentication documentation: http://www.djangoproject.com/documentation/authentication/29 .. _authentication documentation: ../authentication/ 30 30 31 31 comments … … 47 47 See the `csrf documentation`_. 48 48 49 .. _csrf documentation: http://www.djangoproject.com/documentation/csrf/49 .. _csrf documentation: ../csrf/ 50 50 51 51 formtools … … 138 138 See the `flatpages documentation`_. 139 139 140 .. _flatpages documentation: http://www.djangoproject.com/documentation/flatpages/140 .. _flatpages documentation: ../flatpages/ 141 141 142 142 markup … … 158 158 See the `redirects documentation`_. 159 159 160 .. _redirects documentation: http://www.djangoproject.com/documentation/redirects/160 .. _redirects documentation: ../redirects/ 161 161 162 162 sites … … 169 169 See the `sites documentation`_. 170 170 171 .. _sites documentation: http://www.djangoproject.com/documentation/sites/171 .. _sites documentation: ../sites/ 172 172 173 173 sitemaps … … 178 178 See the `sitemaps documentation`_. 179 179 180 .. _sitemaps documentation: http://www.djangoproject.com/documentation/sitemaps/180 .. _sitemaps documentation: ../sitemaps/ 181 181 182 182 syndication … … 187 187 See the `syndication documentation`_. 188 188 189 .. _syndication documentation: http://www.djangoproject.com/documentation/syndication/189 .. _syndication documentation: ../syndication/ 190 190 191 191 Other add-ons django/branches/sqlalchemy/docs/apache_auth.txt
r3918 r4455 66 66 PythonOption DJANGO_SETTINGS_MODULE mysite.settings 67 67 68 .. _authentication system: http://www.djangoproject.com/documentation/authentication/68 .. _authentication system: ../authentication/ 69 69 .. _Subversion: http://subversion.tigris.org/ 70 70 .. _mod_dav: http://httpd.apache.org/docs/2.0/mod/mod_dav.html 71 .. _custom permissions: http://www.djangoproject.com/documentation/authentication/#custom-permissions71 .. _custom permissions: ../authentication/#custom-permissions django/branches/sqlalchemy/docs/api_stability.txt
r3918 r4455 99 99 there will at least be moderate changes. 100 100 101 .. _caching: http://www.djangoproject.com/documentation/cache/102 .. _custom template tags and libraries: http://www.djangoproject.com/documentation/templates_python/103 .. _database lookup: http://www.djangoproject.com/documentation/db_api/104 .. _django-admin utility: http://www.djangoproject.com/documentation/django_admin/105 .. _fastcgi integration: http://www.djangoproject.com/documentation/fastcgi/106 .. _flatpages: http://www.djangoproject.com/documentation/flatpages/107 .. _generic views: http://www.djangoproject.com/documentation/generic_views/108 .. _internationalization: http://www.djangoproject.com/documentation/i18n/109 .. _legacy database integration: http://www.djangoproject.com/documentation/legacy_databases/110 .. _model definition: http://www.djangoproject.com/documentation/model_api/111 .. _mod_python integration: http://www.djangoproject.com/documentation/modpython/112 .. _redirects: http://www.djangoproject.com/documentation/redirects/113 .. _request/response objects: http://www.djangoproject.com/documentation/request_response/114 .. _sending email: http://www.djangoproject.com/documentation/email/115 .. _sessions: http://www.djangoproject.com/documentation/sessions/116 .. _settings: http://www.djangoproject.com/documentation/settings/117 .. _syndication: http://www.djangoproject.com/documentation/syndication/118 .. _template language: http://www.djangoproject.com/documentation/templates/119 .. _transactions: http://www.djangoproject.com/documentation/transactions/120 .. _url dispatch: http://www.djangoproject.com/documentation/url_dispatch/121 .. _forms and validation: http://www.djangoproject.com/documentation/forms/122 .. _serialization: http://www.djangoproject.com/documentation/serialization/123 .. _authentication: http://www.djangoproject.com/documentation/authentication/101 .. _caching: ../cache/ 102 .. _custom template tags and libraries: ../templates_python/ 103 .. _database lookup: ../db_api/ 104 .. _django-admin utility: ../django_admin/ 105 .. _fastcgi integration: ../fastcgi/ 106 .. _flatpages: ../flatpages/ 107 .. _generic views: ../generic_views/ 108 .. _internationalization: ../i18n/ 109 .. _legacy database integration: ../legacy_databases/ 110 .. _model definition: ../model_api/ 111 .. _mod_python integration: ../modpython/ 112 .. _redirects: ../redirects/ 113 .. _request/response objects: ../request_response/ 114 .. _sending email: ../email/ 115 .. _sessions: ../sessions/ 116 .. _settings: ../settings/ 117 .. _syndication: ../syndication/ 118 .. _template language: ../templates/ 119 .. _transactions: ../transactions/ 120 .. _url dispatch: ../url_dispatch/ 121 .. _forms and validation: ../forms/ 122 .. _serialization: ../serialization/ 123 .. _authentication: ../authentication/ django/branches/sqlalchemy/docs/authentication.txt
r4054 r4455 145 145 doesn't allow profiles. 146 146 147 .. _Django model: http://www.djangoproject.com/documentation/model_api/148 .. _DEFAULT_FROM_EMAIL: http://www.djangoproject.com/documentation/settings/#default-from-email147 .. _Django model: ../model_api/ 148 .. _DEFAULT_FROM_EMAIL: ../settings/#default-from-email 149 149 150 150 Manager functions … … 272 272 # Do something for anonymous users. 273 273 274 .. _request objects: http://www.djangoproject.com/documentation/request_response/#httprequest-objects275 .. _session documentation: http://www.djangoproject.com/documentation/sessions/274 .. _request objects: ../request_response/#httprequest-objects 275 .. _session documentation: ../sessions/ 276 276 277 277 How to log a user in … … 442 442 {% endblock %} 443 443 444 .. _forms documentation: http://www.djangoproject.com/documentation/forms/445 .. _site framework docs: http://www.djangoproject.com/documentation/sites/444 .. _forms documentation: ../forms/ 445 .. _site framework docs: ../sites/ 446 446 447 447 Limiting access to logged-in users that pass a test … … 545 545 return object_detail(*args, **kwargs) 546 546 547 .. _generic view: http://www.djangoproject.com/documentation/generic_views/547 .. _generic view: ../generic_views/ 548 548 549 549 Permissions … … 607 607 ``syncdb``. 608 608 609 .. _model Meta attribute: http://www.djangoproject.com/documentation/model_api/#meta-options609 .. _model Meta attribute: ../model_api/#meta-options 610 610 611 611 API reference … … 646 646 For more, see the `RequestContext docs`_. 647 647 648 .. _RequestContext docs: http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext648 .. _RequestContext docs: ../templates_python/#subclassing-context-requestcontext 649 649 650 650 Users … … 692 692 {% endif %} 693 693 694 .. _template context: http://www.djangoproject.com/documentation/templates_python/694 .. _template context: ../templates_python/ 695 695 696 696 Groups … … 757 757 database. To send messages to anonymous users, use the `session framework`_. 758 758 759 .. _session framework: http://www.djangoproject.com/documentation/sessions/759 .. _session framework: ../sessions/ 760 760 761 761 Other authentication sources django/branches/sqlalchemy/docs/cache.txt
r3604 r4455 251 251 See the `middleware documentation`_ for more on middleware. 252 252 253 .. _`middleware documentation`: http://www.djangoproject.com/documentation/middleware/253 .. _`middleware documentation`: ../middleware/ 254 254 255 255 The per-view cache django/branches/sqlalchemy/docs/contributing.txt
r3918 r4455 23 23 back it up. 24 24 25 * Triage patches that have been submitted by other users. Please read 26 `Ticket triage`_ below, for details on the triage process. 27 25 28 That's all you need to know if you'd like to join the Django development 26 29 community. The rest of this document describes the details of how our community … … 45 48 * **Do** write complete, reproducible, specific bug reports. Include as 46 49 much information as you possibly can, complete with code snippets, test 47 cases, etc. A minimal example that illustrates the bug in a nice small 48 test case is the best possible bug report. 50 cases, etc. This means including a clear, concise description of the 51 problem, and a clear set of instructions for replicating the problem. 52 A minimal example that illustrates the bug in a nice small test case 53 is the best possible bug report. 49 54 50 55 * **Don't** use the ticket system to ask support questions. Use the … … 118 123 tracker apply correct syntax highlighting, which is quite helpful. 119 124 120 * Put the prefix "[patch] " before the title of your ticket. This will make 121 it obvious that the ticket includes a patch, and it will add the ticket 122 to the `list of tickets with patches`_. 125 * Check the "Has patch" box on the ticket details. This will make it 126 obvious that the ticket includes a patch, and it will add the ticket to 127 the `list of tickets with patches`_. 128 129 * The code required to fix a problem or add a feature is an essential part 130 of a patch, but it is not the only part. A good patch should also include 131 a regression test to validate the behavior that has been fixed (and prevent 132 the problem from arising again). 133 134 * If the code associated with a patch adds a new feature, or modifies behavior 135 of an existing feature, the patch should also contain documentation. 136 137 Non-trivial patches 138 ------------------- 139 140 A "non-trivial" patch is one that is more than a simple bug fix. It's a patch 141 that introduces Django functionality and makes some sort of design decision. 142 143 If you provide a non-trivial patch, include evidence that alternatives have 144 been discussed on `django-developers`_. If you're not sure whether your patch 145 should be considered non-trivial, just ask. 146 147 Ticket triage 148 ============= 149 150 Unfortunately, not all bug reports in the `ticket tracker`_ provide all 151 the `required details`_. A number of tickets have patches, but those patches 152 don't meet all the requirements of a `good patch`_. 153 154 One way to help out is to *triage* bugs that have been reported by other 155 users. A couple of dedicated volunteers work on this regularly, but more help 156 is always appreciated. 157 158 Most of the workflow is based around the concept of a ticket's "triage stage". 159 This stage describes where in its lifetime a given ticket is at any time. 160 Along with a handful of flags, this field easily tells us what and who each 161 ticket is waiting on. 162 163 Since a picture is worth a thousand words, let's start there: 164 165 .. image:: http://media.djangoproject.com/img/doc/djangotickets.png 166 :height: 451 167 :width: 590 168 :alt: Django's ticket workflow 169 170 We've got two roles here: 171 172 * Core developers: people with commit access who make the decisions and 173 write the bulk of the code. 174 175 * Ticket triagers: community members who keep track of tickets, making 176 sure the tickets are always categorized correctly. 177 178 Second, note the four triage stages: 179 180 1. A ticket starts as "Unreviewed", meaning that a triager has yet to 181 examine the ticket and move it along. 182 183 2. "Design decision needed" means "this concept requires a design 184 decision," which should be discussed either in the ticket comments or on 185 django-developers. 186 187 3. Once a ticket is ruled to be approved for fixing, it's moved into the 188 "Accepted" stage. This stage is where all the real work gets done. 189 190 4. If a ticket has an associated patch (see below), a triager will review the 191 patch. If the patch is complete, it'll be marked as "ready for checkin" so 192 that a core developer knows to review and check in the patches. 193 194 The second part of this workflow involves a set of flags the describe what the 195 ticket has or needs in order to be "ready for checkin": 196 197 "Has patch" 198 The means the ticket has an associated patch_. These will be 199 reviewed to see if the patch is "good". 200 201 "Needs documentation" 202 This flag is used for tickets with patches that need associated 203 documentation. Complete documentation of features is a prerequisite 204 before we can check a fix into the codebase. 205 206 "Needs tests" 207 This flags the patch as needing associated unit tests. Again, this is a 208 required part of a valid patch. 209 210 "Patch needs improvement" 211 This flag means that although the ticket *has* a patch, it's not quite 212 ready for checkin. This could mean the patch no longer applies 213 cleanly, or that the code doesn't live up to our standards. 214 215 .. _required details: `Reporting bugs`_ 216 .. _good patch: `Patch style`_ 217 .. _patch: `Submitting patches`_ 123 218 124 219 Submitting and maintaining translations … … 138 233 139 234 .. _Django i18n mailing list: http://groups.google.com/group/django-i18n/ 140 .. _i18n documentation: http://www.djangoproject.com/documentation/i18n/235 .. _i18n documentation: ../i18n/ 141 236 142 237 Coding style … … 263 358 how to write new tests. 264 359 265 .. _Testing Django applications: http://www.djangoproject.com/documentation/testing/360 .. _Testing Django applications: ../testing/ 266 361 267 362 Running the unit tests … … 339 434 -------------- 340 435 341 To test a given branch, you can simply check out the entire branch, like so:: 436 To use a branch, you'll need to do two things: 437 438 * Get the branch's code through Subversion. 439 440 * Point your Python ``site-packages`` directory at the branch's version of 441 the ``django`` package rather than the version you already have 442 installed. 443 444 Getting the code from Subversion 445 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 446 447 To get the latest version of a branch's code, check it out using Subversion:: 342 448 343 449 svn co http://code.djangoproject.com/svn/django/branches/<branch>/ 344 450 345 Or, if you've got a working directory you'd like to switch to use a branch, 346 you can use:: 451 ...where ``<branch>`` is the branch's name. See the `list of branch names`_. 452 453 Alternatively, you can automatically convert an existing directory of the 454 Django source code as long as you've checked it out via Subversion. To do the 455 conversion, execute this command from within your ``django`` directory:: 347 456 348 457 svn switch http://code.djangoproject.com/svn/django/branches/<branch>/ 349 350 ...in the root of your Django sandbox (the directory that contains ``django``,351 ``docs``, and ``tests``).352 458 353 459 The advantage of using ``svn switch`` instead of ``svn co`` is that the 354 460 ``switch`` command retains any changes you might have made to your local copy 355 of the code. It attempts to merge those changes into the "switched" code. 461 of the code. It attempts to merge those changes into the "switched" code. The 462 disadvantage is that it may cause conflicts with your local changes if the 463 "switched" code has altered the same lines of code. 464 465 (Note that if you use ``svn switch``, you don't need to point Python at the new 466 version, as explained in the next section.) 467 468 .. _list of branch names: http://code.djangoproject.com/browser/django/branches 469 470 Pointing Python at the new Django version 471 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 472 473 Once you've retrieved the branch's code, you'll need to change your Python 474 ``site-packages`` directory so that it points to the branch version of the 475 ``django`` directory. (The ``site-packages`` directory is somewhere such as 476 ``/usr/lib/python2.4/site-packages`` or 477 ``/usr/local/lib/python2.4/site-packages`` or ``C:\Python\site-packages``.) 478 479 The simplest way to do this is by renaming the old ``django`` directory to 480 ``django.OLD`` and moving the trunk version of the code into the directory 481 and calling it ``django``. 482 483 Alternatively, you can use a symlink called ``django`` that points to the 484 location of the branch's ``django`` package. If you want to switch back, just 485 change the symlink to point to the old code. 486 487 If you're using Django 0.95 or earlier and installed it using 488 ``python setup.py install``, you'll have a directory called something like 489 ``Django-0.95-py2.4.egg`` instead of ``django``. In this case, edit the file 490 ``setuptools.pth`` and remove the line that references the Django ``.egg`` 491 file. Then copy the branch's version of the ``django`` directory into 492 ``site-packages``. 356 493 357 494 Official releases … … 458 595 .. _django-users: http://groups.google.com/group/django-users 459 596 .. _`#django`: irc://irc.freenode.net/django 460 .. _list of tickets with patches: http://code.djangoproject.com/ report/12597 .. _list of tickets with patches: http://code.djangoproject.com/query?status=new&status=assigned&status=reopened&has_patch=1&order=priority 461 598 .. _PEP 8: http://www.python.org/peps/pep-0008.html 462 .. _i18n documentation: http://www.djangoproject.com/documentation/i18n/463 599 .. _i18n branch: http://code.djangoproject.com/browser/django/branches/i18n 464 600 .. _`tags/releases`: http://code.djangoproject.com/browser/django/tags/releases django/branches/sqlalchemy/docs/csrf.txt
r2980 r4455 1 1 ===================================== 2 Cross Site Request Forgery Protection2 Cross Site Request Forgery protection 3 3 ===================================== 4 4 5 The CsrfMiddleware class provides easy-to-use protection against 6 `Cross Site Request Forgeries`_. This type of attack occurs when a malicious 5 The CsrfMiddleware class provides easy-to-use protection against 6 `Cross Site Request Forgeries`_. This type of attack occurs when a malicious 7 7 web site creates a link or form button that is intended to perform some action 8 8 on your web site, using the credentials of a logged-in user who is tricked … … 13 13 middleware into your list of installed middleware. 14 14 15 16 15 .. _Cross Site Request Forgeries: http://www.squarefree.com/securitytips/web-developers.html#CSRF 17 16 18 17 How to use it 19 18 ============= 20 Add the middleware ``'django.contrib.csrf.middleware.CsrfMiddleware'`` to 19 20 Add the middleware ``'django.contrib.csrf.middleware.CsrfMiddleware'`` to 21 21 your list of middleware classes, ``MIDDLEWARE_CLASSES``. It needs to process 22 22 the response after the SessionMiddleware, so must come before it in the … … 26 26 How it works 27 27 ============ 28 28 29 CsrfMiddleware does two things: 29 30 30 1. It modifies outgoing requests by adding a hidden form field to all 31 'POST' forms, with the name 'csrfmiddlewaretoken' and a value which is 32 a hash of the session ID plus a secret. If there is no session ID set, 33 this modification of the response isn't done, so there is very little 31 1. It modifies outgoing requests by adding a hidden form field to all 32 'POST' forms, with the name 'csrfmiddlewaretoken' and a value which is 33 a hash of the session ID plus a secret. If there is no session ID set, 34 this modification of the response isn't done, so there is very little 34 35 performance penalty for those requests that don't have a session. 35 36 36 2. On all incoming POST requests that have the session cookie set, it 37 checks that the 'csrfmiddlewaretoken' is present and correct. If it 37 2. On all incoming POST requests that have the session cookie set, it 38 checks that the 'csrfmiddlewaretoken' is present and correct. If it 38 39 isn't, the user will get a 403 error. 39 40 … … 44 45 POST forms). GET requests ought never to have side effects (if you are 45 46 using HTTP GET and POST correctly), and so a CSRF attack with a GET 46 request will always be harmless. 47 request will always be harmless. 47 48 48 49 POST requests that are not accompanied by a session cookie are not protected, … … 50 51 could make these kind of requests anyway. 51 52 52 The Content-Type is checked before modifying the response, and only 53 The Content-Type is checked before modifying the response, and only 53 54 pages that are served as 'text/html' or 'application/xml+xhtml' 54 55 are modified. … … 56 57 Limitations 57 58 =========== 59 58 60 CsrfMiddleware requires Django's session framework to work. If you have 59 61 a custom authentication system that manually sets cookies and the like, 60 62 it won't help you. 61 63 62 If your app creates HTML pages and forms in some unusual way, (e.g. 63 it sends fragments of HTML in javascript document.write statements) 64 you might bypass the filter that adds the hidden field to the form, 64 If your app creates HTML pages and forms in some unusual way, (e.g. 65 it sends fragments of HTML in javascript document.write statements) 66 you might bypass the filter that adds the hidden field to the form, 65 67 in which case form submission will always fail. It may still be possible 66 68 to use the middleware, provided you can find some way to get the 67 69 CSRF token and ensure that is included when your form is submitted. 68 django/branches/sqlalchemy/docs/db-api.txt
r3918 r4455 144 144 145 145 * If the object's primary key attribute is set to a value that evaluates to 146 `` False`` (such as ``None`` or the empty string), Django executes a147 ``SELECT`` query to determine whether a record with the given primary key148 already exists.146 ``True`` (i.e., a value other than ``None`` or the empty string), Django 147 executes a ``SELECT`` query to determine whether a record with the given 148 primary key already exists. 149 149 * If the record with the given primary key does already exist, Django 150 150 executes an ``UPDATE`` query. … … 526 526 >>> Entry.objects.filter(headline__contains='Lennon').dates('pub_date', 'day') 527 527 [datetime.datetime(2005, 3, 20)] 528 529 ``none()`` 530 ~~~~~~~~~~ 531 532 **New in Django development version** 533 534 Returns an ``EmptyQuerySet`` -- a ``QuerySet`` that always evaluates to 535 an empty list. This can be used in cases where you know that you should 536 return an empty result set and your caller is expecting a ``QuerySet`` 537 object (instead of returning an empty list, for example.) 538 539 Examples:: 540 541 >>> Entry.objects.none() 542 [] 528 543 529 544 ``select_related()`` … … 1705 1720 returns the height (or width) of the image, as an integer, in pixels. 1706 1721 1722 Shortcuts 1723 ========= 1724 1725 As you develop views, you will discover a number of common idioms in the 1726 way you use the database API. Django encodes some of these idioms as 1727 shortcuts that can be used to simplify the process of writing views. 1728 1729 get_object_or_404() 1730 ------------------- 1731 1732 One common idiom to use ``get()`` and raise ``Http404`` if the 1733 object doesn't exist. This idiom is captured by ``get_object_or_404()``. 1734 This function takes a Django model as its first argument and an 1735 arbitrary number of keyword arguments, which it passes to the manager's 1736 ``get()`` function. It raises ``Http404`` if the object doesn't 1737 exist. For example:: 1738 1739 # Get the Entry with a primary key of 3 1740 e = get_object_or_404(Entry, pk=3) 1741 1742 When you provide a model to this shortcut function, the default manager 1743 is used to execute the underlying ``get()`` query. If you don't want to 1744 use the default manager, or you want to search a list of related objects, 1745 you can provide ``get_object_or_404()`` with a manager object, instead. 1746 For example:: 1747 1748 # Get the author of blog instance `e` with a name of 'Fred' 1749 a = get_object_or_404(e.authors, name='Fred') 1750 1751 # Use a custom manager 'recent_entries' in the search for an 1752 # entry with a primary key of 3 1753 e = get_object_or_404(Entry.recent_entries, pk=3) 1754 1755 get_list_or_404() 1756 ----------------- 1757 1758 ``get_list_or_404`` behaves the same was as ``get_object_or_404()`` 1759 -- except the it uses using ``filter()`` instead of ``get()``. It raises 1760 ``Http404`` if the list is empty. 1761 1707 1762 Falling back to raw SQL 1708 1763 ======================= django/branches/sqlalchemy/docs/design_philosophies.txt
r3438 r4455 187 187 This is the philosophy behind `template inheritance`_. 188 188 189 .. _template inheritance: http://www.djangoproject.com/documentation/templates/#template-inheritance189 .. _template inheritance: ../templates/#template-inheritance 190 190 191 191 Be decoupled from HTML django/branches/sqlalchemy/docs/django-admin.txt
r3918 r4455 54 54 your admin's index page. See `Tutorial 2`_ for more information. 55 55 56 .. _Tutorial 2: http://www.djangoproject.com/documentation/tutorial2/56 .. _Tutorial 2: ../tutorial2/ 57 57 58 58 createcachetable [tablename] … … 62 62 backend. See the `cache documentation`_ for more information. 63 63 64 .. _cache documentation: http://www.djangoproject.com/documentation/cache/64 .. _cache documentation: ../cache/ 65 65 66 66 dbshell … … 191 191 documentation. 192 192 193 .. _serving static files: http://www.djangoproject.com/documentation/static_files/193 .. _serving static files: ../static_files/ 194 194 195 195 Turning off auto-reload … … 254 254 tables with any necessary initial records, SQL functions or test data. 255 255 256 Note that the order in which the SQL files are processed is undefined. 257 256 258 sqlreset [appname appname ...] 257 259 -------------------------------------- … … 381 383 django-admin.py syncdb --verbosity=2 382 384 383 Verbosity determines the amount of notification and debug information that 385 Verbosity determines the amount of notification and debug information that 384 386 will be printed to the console. '0' is no output, '1' is normal output, 385 387 and `2` is verbose output. django/branches/sqlalchemy/docs/email.txt
r2901 r4455 102 102 This method exists for convenience and readability. 103 103 104 .. _ADMINS setting: http://www.djangoproject.com/documentation/settings/#admins105 .. _EMAIL_SUBJECT_PREFIX setting: http://www.djangoproject.com/documentation/settings/#email-subject-prefix106 .. _SERVER_EMAIL setting: http://www.djangoproject.com/documentation/settings/#server-email104 .. _ADMINS setting: ../settings/#admins 105 .. _EMAIL_SUBJECT_PREFIX setting: ../settings/#email-subject-prefix 106 .. _SERVER_EMAIL setting: ../settings/#server-email 107 107 108 108 mail_managers() function … … 115 115 mail_managers(subject, message, fail_silently=False) 116 116 117 .. _MANAGERS setting: http://www.djangoproject.com/documentation/settings/#managers117 .. _MANAGERS setting: ../settings/#managers 118 118 119 119 Examples django/branches/sqlalchemy/docs/faq.txt
r3918 r4455 64 64 application layer. And it ships with a simple-yet-powerful `cache framework`_. 65 65 66 .. _`cache framework`: http://www.djangoproject.com/documentation/cache/66 .. _`cache framework`: ../cache/ 67 67 68 68 Who's behind this? … … 192 192 We've documented our philosophies on the `design philosophies page`_. 193 193 194 .. _design philosophies page: http://www.djangoproject.com/documentation/design_philosophies/194 .. _design philosophies page: ../design_philosophies/ 195 195 196 196 Do you have any of those nifty "screencast" things? … … 278 278 279 279 .. _`Download the code`: http://www.djangoproject.com/download/ 280 .. _`installation guide`: http://www.djangoproject.com/documentation/install/281 .. _tutorial: http://www.djangoproject.com/documentation/tutorial1/282 .. _documentation: http://www.djangoproject.com/documentation/280 .. _`installation guide`: ../install/ 281 .. _tutorial: ../tutorial1/ 282 .. _documentation: ../ 283 283 .. _ask questions: http://www.djangoproject.com/community/ 284 284 … … 338 338 339 339 .. _WSGI: http://www.python.org/peps/pep-0333.html 340 .. _How to use Django with FastCGI: http://www.djangoproject.com/documentation/fastcgi/340 .. _How to use Django with FastCGI: ../fastcgi/ 341 341 .. _server arrangements wiki page: http://code.djangoproject.com/wiki/ServerArrangements 342 342 … … 465 465 Yes. See `Integrating with a legacy database`_. 466 466 467 .. _`Integrating with a legacy database`: http://www.djangoproject.com/documentation/legacy_databases/467 .. _`Integrating with a legacy database`: ../legacy_databases/ 468 468 469 469 If I make changes to a model, how do I update the database? … … 512 512 contain arbitrary SQL, so you can make any sorts of changes you need to make. 513 513 514 .. _SQL initial data file: http://www.djangoproject.com/documentation/model_api/#providing-initial-sql-data514 .. _SQL initial data file: ../model_api/#providing-initial-sql-data 515 515 516 516 Why is Django leaking memory? … … 593 593 documentation. 594 594 595 .. _serving the admin files: http://www.djangoproject.com/documentation/modpython/#serving-the-admin-files595 .. _serving the admin files: ../modpython/#serving-the-admin-files 596 596 597 597 My "list_filter" contains a ManyToManyField, but the filter doesn't display. … … 631 631 `guide to the CSS used in the admin`_ to get you started. 632 632 633 .. _`guide to the CSS used in the admin`: http://www.djangoproject.com/documentation/admin_css/633 .. _`guide to the CSS used in the admin`: ../admin_css/ 634 634 635 635 How do I create users without having to edit password hashes? … … 641 641 You can also use the Python API. See `creating users`_ for full info. 642 642 643 .. _creating users: http://www.djangoproject.com/documentation/authentication/#creating-users643 .. _creating users: ../authentication/#creating-users 644 644 645 645 Contributing code … … 652 652 It's titled `Contributing to Django`_. 653 653 654 .. _Contributing to Django: http://www.djangoproject.com/documentation/contributing/654 .. _Contributing to Django: ../contributing/ 655 655 656 656 I submitted a bug fix in the ticket system several weeks ago. Why are you ignoring my patch? django/branches/sqlalchemy/docs/fastcgi.txt
r3770 r4455 18 18 persistent process. 19 19 20 .. _current preferred setup: http://www.djangoproject.com/documentation/modpython/20 .. _current preferred setup: ../modpython/ 21 21 .. _Apache: http://httpd.apache.org/ 22 22 .. _mod_python: http://www.modpython.org/ django/branches/sqlalchemy/docs/flatpages.txt
r2813 r4455 30 30 3. Run the command ``manage.py syncdb``. 31 31 32 .. _INSTALLED_APPS: http://www.djangoproject.com/documentation/settings/#installed-apps33 .. _MIDDLEWARE_CLASSES: http://www.djangoproject.com/documentation/settings/#middleware-classes32 .. _INSTALLED_APPS: ../settings/#installed-apps 33 .. _MIDDLEWARE_CLASSES: ../settings/#middleware-classes 34 34 35 35 How it works … … 64 64 For more on middleware, read the `middleware docs`_. 65 65 66 .. _SITE_ID: http://www.djangoproject.com/documentation/settings/#site-id67 .. _RequestContext: http://www.djangoproject.com/documentation/templates_python/#subclassing-context-djangocontext68 .. _middleware docs: http://www.djangoproject.com/documentation/middleware/66 .. _SITE_ID: ../settings/#site-id 67 .. _RequestContext: ../templates_python/#subclassing-context-djangocontext 68 .. _middleware docs: ../middleware/ 69 69 70 70 How to add, change and delete flatpages … … 85 85 `Django database API`_. 86 86 87 .. _Django model: http://www.djangoproject.com/documentation/model_api/87 .. _Django model: ../model_api/ 88 88 .. _django/contrib/flatpages/models.py: http://code.djangoproject.com/browser/django/trunk/django/contrib/flatpages/models.py 89 .. _Django database API: http://www.djangoproject.com/documentation/db_api/89 .. _Django database API: ../db_api/ 90 90 91 91 Flatpage templates django/branches/sqlalchemy/docs/forms.txt
r4054 r4455 3 3 =============================== 4 4 5 Forwards-compatibility note 6 =========================== 7 8 The legacy forms/manipulators system described in this document is going to be 9 replaced in the next Django release. If you're starting from scratch, we 10 strongly encourage you not to waste your time learning this. Instead, learn and 11 use the django.newforms system, which we have begun to document in the 12 `newforms documentation`_. 13 14 If you have legacy form/manipulator code, read the "Migration plan" section in 15 that document to understand how we're making the switch. 16 17 .. _newforms documentation: ../newforms/ 18 19 Introduction 20 ============ 21 5 22 Once you've got a chance to play with Django's admin interface, you'll probably 6 23 wonder if the fantastic form validation framework it uses is available to user 7 24 code. It is, and this document explains how the framework works. 8 9 .. admonition:: A note to the lazy10 11 If all you want to do is present forms for a user to create and/or12 update a given object, you may be able to use `generic views`_.13 25 14 26 We'll take a top-down approach to examining Django's form validation framework, … … 42 54 but what if you want to allow public users to submit places? 43 55 44 Manipulators45 ============ 56 Automatic Manipulators 57 ====================== 46 58 47 59 The highest-level interface for object creation and modification is the 48 ** Manipulator** framework. A manipulator is a utility class tied to a given49 model that "knows" how to create or modify instances of that model and how to 50 validate data for the object. Manipulators come in two flavors: 51 ``AddManipulators`` and ``ChangeManipulators``. Functionally they are quite 52 similar, but the former knows how to create new instances of the model, while53 the latter modifies existing instances. Both types of classes are automatically 54 created when you define a new class::60 **automatic Manipulator** framework. An automatic manipulator is a utility 61 class tied to a given model that "knows" how to create or modify instances of 62 that model and how to validate data for the object. Automatic Manipulators come 63 in two flavors: ``AddManipulators`` and ``ChangeManipulators``. Functionally 64 they are quite similar, but the former knows how to create new instances of the 65 model, while the latter modifies existing instances. Both types of classes are 66 automatically created when you define a new class:: 55 67 56 68 >>> from mysite.myapp.models import Place … … 654 666 document for more details). 655 667 656 .. _`generic views`: http://www.djangoproject.com/documentation/generic_views/657 .. _`models API`: http://www.djangoproject.com/documentation/model_api/658 .. _settings: http://www.djangoproject.com/documentation/settings/668 .. _`generic views`: ../generic_views/ 669 .. _`models API`: ../model_api/ 670 .. _settings: ../settings/ django/branches/sqlalchemy/docs/generic_views.txt
r4054 r4455 72 72 lambda that returns the QuerySet. 73 73 74 .. _database API docs: http://www.djangoproject.com/documentation/db_api/74 .. _database API docs: ../db_api/ 75 75 76 76 "Simple" generic views … … 100 100 just before rendering the template. (**This is new in the 101 101 Django development version.**) 102 102 103 103 **Example:** 104 104 <… …
