Changeset 5825
- Timestamp:
- 08/06/07 21:33:11 (1 year ago)
- Files:
-
- django/trunk/docs/contributing.txt (modified) (1 diff)
- django/trunk/docs/i18n.txt (modified) (1 diff)
- django/trunk/docs/model-api.txt (modified) (8 diffs)
- django/trunk/docs/overview.txt (modified) (3 diffs)
- django/trunk/docs/tutorial01.txt (modified) (3 diffs)
- django/trunk/docs/tutorial02.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/contributing.txt
r5803 r5825 546 546 547 547 Yes, the unit tests need a settings module, but only for database connection 548 info -- the ``DATABASE_NAME`` (required, but will be ignored), 549 ``DATABASE_ENGINE``, ``DATABASE_USER`` and ``DATABASE_PASSWORD`` settings. You 550 will also need a ``ROOT_URLCONF`` setting (its value is ignored; it just needs 551 to be present) and a ``SITE_ID`` setting (any non-zero integer value will do) 552 in order for all the tests to pass. 548 info, with the ``DATABASE_ENGINE`` setting. You will also need a ``ROOT_URLCONF`` 549 setting (its value is ignored; it just needs to be present) and a ``SITE_ID`` 550 setting (any non-zero integer value will do) in order for all the tests to pass. 553 551 554 552 The unit tests will not touch your existing databases; they create a new django/trunk/docs/i18n.txt
r5609 r5825 264 264 ``ugettext`` / ``ungettext`` call. 265 265 266 Each ``RequestContext`` has access to t wotranslation-specific variables:266 Each ``RequestContext`` has access to three translation-specific variables: 267 267 268 268 * ``LANGUAGES`` is a list of tuples in which the first element is the django/trunk/docs/model-api.txt
r5816 r5825 151 151 the old ``maxlength`` argument, but ``max_length`` is prefered. 152 152 153 ``CommaSeparatedIntegerField``153 ``CommaSeparatedIntegerField`` 154 154 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 155 155 … … 738 738 any other ``Field`` type: by including it as a class attribute of your model. 739 739 740 ``ForeignKey`` requires a positional argument: The class to which the model is740 ``ForeignKey`` requires a positional argument: the class to which the model is 741 741 related. 742 742 … … 873 873 model. 874 874 875 ``ManyToManyField`` requires a positional argument: The class to which the875 ``ManyToManyField`` requires a positional argument: the class to which the 876 876 model is related. 877 877 … … 970 970 another object in some way. 971 971 972 ``OneToOneField`` requires a positional argument: The class to which the972 ``OneToOneField`` requires a positional argument: the class to which the 973 973 model is related. 974 974 … … 1422 1422 A few special cases to note about ``list_display``: 1423 1423 1424 * If the field is a ``ForeignKey``, Django will display the ``__str__()``1425 of the related object.1424 * If the field is a ``ForeignKey``, Django will display the 1425 ``__unicode__()`` of the related object. 1426 1426 1427 1427 * ``ManyToManyField`` fields aren't supported, because that would entail … … 1673 1673 1674 1674 Note that the query input is split by spaces, so, following this example, 1675 it's notcurrently not possible to search for all records in which1675 it's currently not possible to search for all records in which 1676 1676 ``first_name`` is exactly ``'john winston'`` (containing a space). 1677 1677 … … 1957 1957 method. 1958 1958 1959 .. syndication feed framework: ../syndication_feeds/1959 .. _syndication feed framework: ../syndication_feeds/ 1960 1960 1961 1961 It's good practice to use ``get_absolute_url()`` in templates, instead of … … 2016 2016 get_absolute_url = permalink(get_absolute_url) 2017 2017 2018 Notice that we specify an empty sequence for the second argumentin this case,2019 because we only want to pass keyword arguments, not named arguments.2018 Notice that we specify an empty sequence for the second parameter in this case, 2019 because we only want to pass keyword parameters, not positional ones. 2020 2020 2021 2021 In this way, you're tying the model's absolute URL to the view that is used django/trunk/docs/overview.txt
r5803 r5825 55 55 56 56 With that, you've got a free, and rich, Python API to access your data. The API 57 is created on the fly : No code generation necessary::57 is created on the fly, no code generation necessary:: 58 58 59 59 >>> from mysite.models import Reporter, Article … … 125 125 >>> r.delete() 126 126 127 A dynamic admin interface: It's not just scaffolding -- it's the whole house127 A dynamic admin interface: it's not just scaffolding -- it's the whole house 128 128 ============================================================================ 129 129 … … 251 251 'base', which has defined a bunch of blocks, and fill the blocks with the 252 252 following blocks." In short, that lets you dramatically cut down on redundancy 253 in templates: Each template has to define only what's unique to that template.253 in templates: each template has to define only what's unique to that template. 254 254 255 255 Here's what the "base.html" template might look like:: django/trunk/docs/tutorial01.txt
r5803 r5825 462 462 "What's up?" 463 463 >>> p.pub_date 464 datetime.datetime(200 5, 7, 15, 12, 00, 53)464 datetime.datetime(2007, 7, 15, 12, 00, 53) 465 465 466 466 # Change values by changing the attributes, then calling save(). 467 >>> p.pub_date = datetime(200 5, 4, 1, 0, 0)467 >>> p.pub_date = datetime(2007, 4, 1, 0, 0) 468 468 >>> p.save() 469 469 … … 538 538 [<Poll: What's up?>] 539 539 540 # Get the poll whose year is 200 5. Of course, if you're going through this540 # Get the poll whose year is 2007. Of course, if you're going through this 541 541 # tutorial in another year, change as appropriate. 542 >>> Poll.objects.get(pub_date__year=200 5)542 >>> Poll.objects.get(pub_date__year=2007) 543 543 <Poll: What's up?> 544 544 … … 581 581 # The API automatically follows relationships as far as you need. 582 582 # Use double underscores to separate relationships. 583 # This works as many levels deep as you want . There's no limit.584 # Find all Choices for any poll whose pub_date is in 200 5.585 >>> Choice.objects.filter(poll__pub_date__year=200 5)583 # This works as many levels deep as you want; there's no limit. 584 # Find all Choices for any poll whose pub_date is in 2007. 585 >>> Choice.objects.filter(poll__pub_date__year=2007) 586 586 [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>] 587 587 django/trunk/docs/tutorial02.txt
r5803 r5825 363 363 ================================= 364 364 365 Clearly, having "Django administration" a nd "example.com" at the top of each366 admin page isridiculous. It's just placeholder text.365 Clearly, having "Django administration" at the top of each admin page is 366 ridiculous. It's just placeholder text. 367 367 368 368 That's easy to change, though, using Django's template system. The Django admin … … 390 390 391 391 Then, just edit the file and replace the generic Django text with your own 392 site's name a nd URL as you see fit.392 site's name as you see fit. 393 393 394 394 Note that any of Django's default admin templates can be overridden. To
