Django

Code

Show
Ignore:
Timestamp:
08/06/07 11:50:17 (1 year ago)
Author:
danderson
Message:

schema-evolution: update from HEAD (v5821)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/schema-evolution/docs/add_ons.txt

    r5734 r5822  
    215215See the `syndication documentation`_. 
    216216 
    217 .. _syndication documentation: ../syndication
     217.. _syndication documentation: ../syndication_feeds
    218218 
    219219Other add-ons 
  • django/branches/schema-evolution/docs/api_stability.txt

    r5734 r5822  
    8383change: 
    8484 
    85    - `Forms and validation`_ will most likely be completely rewritten to 
    86      deemphasize Manipulators in favor of validation-aware models. 
    87  
    8885   - `Serialization`_ is under heavy development; changes are likely. 
    8986 
     
    115112.. _sessions: ../sessions/ 
    116113.. _settings: ../settings/ 
    117 .. _syndication: ../syndication
     114.. _syndication: ../syndication_feeds
    118115.. _template language: ../templates/ 
    119116.. _transactions: ../transactions/ 
  • django/branches/schema-evolution/docs/authentication.txt

    r5788 r5822  
    235235Previous Django versions, such as 0.90, used simple MD5 hashes without password 
    236236salts. For backwards compatibility, those are still supported; they'll be 
    237 converted automatically to the new style the first time ``check_password()`` 
     237converted automatically to the new style the first time ``User.check_password()`` 
    238238works correctly for a given user. 
    239239 
  • django/branches/schema-evolution/docs/contributing.txt

    r5788 r5822  
    341341 
    342342          class Person(models.Model): 
    343               first_name = models.CharField(maxlength=20) 
    344               last_name = models.CharField(maxlength=40) 
     343              first_name = models.CharField(max_length=20) 
     344              last_name = models.CharField(max_length=40) 
    345345 
    346346      Don't do this:: 
    347347 
    348348          class Person(models.Model): 
    349               FirstName = models.CharField(maxlength=20) 
    350               Last_Name = models.CharField(maxlength=40) 
     349              FirstName = models.CharField(max_length=20) 
     350              Last_Name = models.CharField(max_length=40) 
    351351 
    352352    * The ``class Meta`` should appear *after* the fields are defined, with 
     
    356356 
    357357          class Person(models.Model): 
    358               first_name = models.CharField(maxlength=20) 
    359               last_name = models.CharField(maxlength=40) 
     358              first_name = models.CharField(max_length=20) 
     359              last_name = models.CharField(max_length=40) 
    360360 
    361361              class Meta: 
     
    365365 
    366366          class Person(models.Model): 
    367               first_name = models.CharField(maxlength=20) 
    368               last_name = models.CharField(maxlength=40) 
     367              first_name = models.CharField(max_length=20) 
     368              last_name = models.CharField(max_length=40) 
    369369              class Meta: 
    370370                  verbose_name_plural = 'people' 
     
    376376                  verbose_name_plural = 'people' 
    377377 
    378               first_name = models.CharField(maxlength=20) 
    379               last_name = models.CharField(maxlength=40) 
     378              first_name = models.CharField(max_length=20) 
     379              last_name = models.CharField(max_length=40) 
    380380 
    381381    * The order of model inner classes and standard methods should be as 
  • django/branches/schema-evolution/docs/databases.txt

    r5734 r5822  
    125125`MySQLdb documentation`_ for more details. 
    126126 
    127 .. _settings documentation: http://www.djangoproject.com/documentation/settings/#database-engine 
     127.. _settings documentation: ../settings/#database-engine 
    128128.. _MySQL option file: http://dev.mysql.com/doc/refman/5.0/en/option-files.html 
    129129.. _MySQLdb documentation: http://mysql-python.sourceforge.net/ 
  • django/branches/schema-evolution/docs/db-api.txt

    r5788 r5822  
    1313 
    1414    class Blog(models.Model): 
    15         name = models.CharField(maxlength=100) 
     15        name = models.CharField(max_length=100) 
    1616        tagline = models.TextField() 
    1717 
     
    2020 
    2121    class Author(models.Model): 
    22         name = models.CharField(maxlength=50) 
     22        name = models.CharField(max_length=50) 
    2323        email = models.EmailField() 
    2424 
     
    2828    class Entry(models.Model): 
    2929        blog = models.ForeignKey(Blog) 
    30         headline = models.CharField(maxlength=255) 
     30        headline = models.CharField(max_length=255) 
    3131        body_text = models.TextField() 
    3232        pub_date = models.DateTimeField() 
     
    15041504See the `OR lookups examples page`_ for more examples. 
    15051505 
    1506 .. _OR lookups examples page: http://www.djangoproject.com/documentation/models/or_lookups/ 
     1506.. _OR lookups examples page: ../models/or_lookups/ 
    15071507 
    15081508Related objects 
     
    18071807    ) 
    18081808    class Person(models.Model): 
    1809         name = models.CharField(maxlength=20) 
    1810         gender = models.CharField(maxlength=1, choices=GENDER_CHOICES) 
     1809        name = models.CharField(max_length=20) 
     1810        gender = models.CharField(max_length=1, choices=GENDER_CHOICES) 
    18111811 
    18121812...each ``Person`` instance will have a ``get_gender_display()`` method. Example:: 
     
    18351835For a full example, see the `lookup API sample model`_. 
    18361836 
    1837 .. _lookup API sample model: http://www.djangoproject.com/documentation/models/lookup/ 
     1837.. _lookup API sample model: ../models/lookup/ 
    18381838 
    18391839get_FOO_filename() 
  • django/branches/schema-evolution/docs/email.txt

    r5734 r5822  
    315315    subject, from_email, to = 'hello', 'from@example.com', 'to@example.com' 
    316316    text_content = 'This is an important message.' 
    317     html_content = '<p>This is an <strong>important</strong> message.
     317    html_content = '<p>This is an <strong>important</strong> message.</p>
    318318    msg = EmailMultiAlternatives(subject, text_content, from_email, to) 
    319319    msg.attach_alternative(html_content, "text/html") 
  • django/branches/schema-evolution/docs/faq.txt

    r5734 r5822  
    4343Django is pronounced **JANG**-oh. Rhymes with FANG-oh. The "D" is silent. 
    4444 
     45We've also recorded an `audio clip of the pronunciation`_. 
     46 
    4547.. _Django Reinhardt: http://en.wikipedia.org/wiki/Django_Reinhardt 
     48.. _audio clip of the pronunciation: http://red-bean.com/~adrian/django_pronunciation.mp3 
    4649 
    4750Is Django stable? 
  • django/branches/schema-evolution/docs/forms.txt

    r5734 r5822  
    3838 
    3939    class Place(models.Model): 
    40         name = models.CharField(maxlength=100) 
    41         address = models.CharField(maxlength=100, blank=True) 
    42         city = models.CharField(maxlength=50, blank=True) 
     40        name = models.CharField(max_length=100) 
     41        address = models.CharField(max_length=100, blank=True) 
     42        city = models.CharField(max_length=50, blank=True) 
    4343        state = models.USStateField() 
    44         zip_code = models.CharField(maxlength=5, blank=True) 
     44        zip_code = models.CharField(max_length=5, blank=True) 
    4545        place_type = models.IntegerField(choices=PLACE_TYPES) 
    4646 
     
    389389            self.fields = ( 
    390390                forms.EmailField(field_name="from", is_required=True), 
    391                 forms.TextField(field_name="subject", length=30, maxlength=200, is_required=True), 
     391                forms.TextField(field_name="subject", length=30, max_length=200, is_required=True), 
    392392                forms.SelectField(field_name="urgency", choices=urgency_choices), 
    393393                forms.LargeTextField(field_name="contents", is_required=True), 
  • django/branches/schema-evolution/docs/model-api.txt

    r5788 r5822  
    2323 
    2424.. _Database API reference: ../db-api/ 
    25 .. _official repository of model examples: http://www.djangoproject.com/documentation/models/ 
     25.. _official repository of model examples: ../models/ 
    2626 
    2727Quick example 
     
    3434 
    3535    class Person(models.Model): 
    36         first_name = models.CharField(maxlength=30) 
    37         last_name = models.CharField(maxlength=30) 
     36        first_name = models.CharField(max_length=30) 
     37        last_name = models.CharField(max_length=30) 
    3838 
    3939``first_name`` and ``last_name`` are *fields* of the model. Each field is 
     
    7070 
    7171    class Musician(models.Model): 
    72         first_name = models.CharField(maxlength=50) 
    73         last_name = models.CharField(maxlength=50) 
    74         instrument = models.CharField(maxlength=100) 
     72        first_name = models.CharField(max_length=50) 
     73        last_name = models.CharField(max_length=50) 
     74        instrument = models.CharField(max_length=100) 
    7575 
    7676    class Album(models.Model): 
    7777        artist = models.ForeignKey(Musician) 
    78         name = models.CharField(maxlength=100) 
     78        name = models.CharField(max_length=100) 
    7979        release_date = models.DateField() 
    8080        num_stars = models.IntegerField() 
     
    143143The admin represents this as an ``<input type="text">`` (a single-line input). 
    144144 
    145 ``CharField`` has an extra required argument, ``maxlength``, the maximum length 
    146 (in characters) of the field. The maxlength is enforced at the database level 
     145``CharField`` has an extra required argument, ``max_length``, the maximum length 
     146(in characters) of the field. The max_length is enforced at the database level 
    147147and in Django's validation. 
    148148 
    149 ``CommaSeparatedIntegerField`` 
     149Django veterans: Note that the argument is now called ``max_length`` to 
     150provide consistency throughout Django. There is full legacy support for 
     151the old ``maxlength`` argument, but ``max_length`` is prefered. 
     152         
     153 ``CommaSeparatedIntegerField`` 
    150154~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    151155 
    152 A field of integers separated by commas. As in ``CharField``, the ``maxlength`` 
     156A field of integers separated by commas. As in ``CharField``, the ``max_length`` 
    153157argument is required. 
    154158 
     
    218222 
    219223A ``CharField`` that checks that the value is a valid e-mail address. 
    220 This doesn't accept ``maxlength``; its ``maxlength`` is automatically set to 
     224This doesn't accept ``max_length``; its ``max_length`` is automatically set to 
    22122575. 
    222226 
     
    401405used in URLs. 
    402406 
    403 Like a CharField, you can specify ``maxlength``. If ``maxlength`` is 
     407Like a CharField, you can specify ``max_length``. If ``max_length`` is 
    404408not specified, Django will use a default length of 50. 
    405409 
     
    448452The admin represents this as an ``<input type="text">`` (a single-line input). 
    449453 
    450 ``URLField`` takes an optional argument, ``maxlength``, the maximum length (in 
    451 characters) of the field. The maxlength is enforced at the database level and 
    452 in Django's validation. If you don't specify ``maxlength``, a default of 200 
     454``URLField`` takes an optional argument, ``max_length``, the maximum length (in 
     455characters) of the field. The maximum length is enforced at the database level and 
     456in Django's validation. If you don't specify ``max_length``, a default of 200 
    453457is used. 
    454458 
     
    537541            ('F', 'Female'), 
    538542        ) 
    539         gender = models.CharField(maxlength=1, choices=GENDER_CHOICES) 
     543        gender = models.CharField(max_length=1, choices=GENDER_CHOICES) 
    540544 
    541545or outside your model class altogether:: 
     
    546550    ) 
    547551    class Foo(models.Model): 
    548         gender = models.CharField(maxlength=1, choices=GENDER_CHOICES) 
     552        gender = models.CharField(max_length=1, choices=GENDER_CHOICES) 
    549553 
    550554For each model field that has ``choices`` set, Django will add a method to 
     
    621625admin form. 
    622626 
     627Note that this value is *not* HTML-escaped when it's displayed in the admin 
     628interface. This lets you include HTML in ``help_text`` if you so desire. For 
     629example:: 
     630 
     631        help_text="Please use the following format: <em>YYYY-MM-DD</em>." 
     632 
    623633``primary_key`` 
    624634~~~~~~~~~~~~~~~ 
     
    699709In this example, the verbose name is ``"Person's first name"``:: 
    700710 
    701     first_name = models.CharField("Person's first name", maxlength=30) 
     711    first_name = models.CharField("Person's first name", max_length=30) 
    702712 
    703713In this example, the verbose name is ``"first name"``:: 
    704714 
    705     first_name = models.CharField(maxlength=30) 
     715    first_name = models.CharField(max_length=30) 
    706716 
    707717``ForeignKey``, ``ManyToManyField`` and ``OneToOneField`` require the first 
     
    776786See the `Many-to-one relationship model example`_ for a full example. 
    777787 
    778 .. _Many-to-one relationship model example: http://www.djangoproject.com/documentation/models/many_to_one/ 
     788.. _Many-to-one relationship model example: ../models/many_to_one/ 
    779789 
    780790``ForeignKey`` fields take a number of extra arguments for defining how the 
     
    903913See the `Many-to-many relationship model example`_ for a full example. 
    904914 
    905 .. _Many-to-many relationship model example: http://www.djangoproject.com/documentation/models/many_to_many/ 
     915.. _Many-to-many relationship model example: ../models/many_to_many/ 
    906916 
    907917``ManyToManyField`` objects take a number of extra arguments for defining how 
     
    980990See the `One-to-one relationship model example`_ for a full example. 
    981991 
    982 .. _One-to-one relationship model example: http://www.djangoproject.com/documentation/models/one_to_one/ 
     992.. _One-to-one relationship model example: ../models/one_to_one/ 
    983993 
    984994Custom field types 
     
    10281038 
    10291039    class Person(models.Model): 
    1030         name = models.CharField(maxlength=80) 
    1031         gender = models.CharField(maxlength=1) 
     1040        name = models.CharField(max_length=80) 
     1041        gender = models.CharField(max_length=1) 
    10321042        something_else = MytypeField() 
    10331043 
     
    10751085    # This is a much more flexible example. 
    10761086    class BetterCharField(models.Field): 
    1077         def __init__(self, maxlength, *args, **kwargs): 
    1078             self.maxlength = maxlength 
     1087        def __init__(self, max_length, *args, **kwargs): 
     1088            self.max_length = max_length 
    10791089            super(BetterCharField, self).__init__(*args, **kwargs) 
    10801090 
    10811091        def db_type(self): 
    1082             return 'char(%s)' % self.maxlength 
     1092            return 'char(%s)' % self.max_length 
    10831093 
    10841094    # In the model: 
     
    10971107 
    10981108    class Foo(models.Model): 
    1099         bar = models.CharField(maxlength=30) 
     1109        bar = models.CharField(max_length=30) 
    11001110 
    11011111        class Meta: 
     
    11871197site uses only the first field. 
    11881198 
    1189 .. _Specifying ordering: http://www.djangoproject.com/documentation/models/ordering/ 
     1199.. _Specifying ordering: ../models/ordering/ 
    11901200 
    11911201``permissions`` 
     
    12711281 
    12721282    class Person(models.Model): 
    1273         first_name = models.CharField(maxlength=30) 
    1274         last_name = models.CharField(maxlength=30) 
     1283        first_name = models.CharField(max_length=30) 
     1284        last_name = models.CharField(max_length=30) 
    12751285 
    12761286        class Admin: 
     
    14311441 
    14321442          class Person(models.Model): 
    1433               name = models.CharField(maxlength=50) 
     1443              name = models.CharField(max_length=50) 
    14341444              birthday = models.DateField() 
    14351445 
     
    14481458 
    14491459          class Person(models.Model): 
    1450               first_name = models.CharField(maxlength=50) 
    1451               last_name = models.CharField(maxlength=50) 
    1452               color_code = models.CharField(maxlength=6) 
     1460              first_name = models.CharField(max_length=50) 
     1461              last_name = models.CharField(max_length=50) 
     1462              color_code = models.CharField(max_length=6) 
    14531463 
    14541464              class Admin: 
     
    14661476 
    14671477          class Person(models.Model): 
    1468               first_name = models.CharField(maxlength=50) 
     1478              first_name = models.CharField(max_length=50) 
    14691479              birthday = models.DateField() 
    14701480 
     
    14941504 
    14951505        class Person(models.Model): 
    1496             first_name = models.CharField(maxlength=50) 
    1497             color_code = models.CharField(maxlength=6) 
     1506            first_name = models.CharField(max_length=50) 
     1507            color_code = models.CharField(max_length=6) 
    14981508 
    14991509            class Admin: 
     
    17451755 
    17461756    class OpinionPoll(models.Model): 
    1747         question = models.CharField(maxlength=200) 
     1757        question = models.CharField(max_length=200) 
    17481758        poll_date = models.DateField() 
    17491759        objects = PollManager() 
     
    17511761    class Response(models.Model): 
    17521762        poll = models.ForeignKey(Poll) 
    1753         person_name = models.CharField(maxlength=50) 
     1763        person_name = models.CharField(max_length=50) 
    17541764        response = models.TextField() 
    17551765 
     
    17671777 
    17681778    class Book(models.Model): 
    1769         title = models.CharField(maxlength=100) 
    1770         author = models.CharField(maxlength=50) 
     1779        title = models.CharField(max_length=100) 
     1780        author = models.CharField(max_length=50) 
    17711781 
    17721782...the statement ``Book.objects.all()`` will return all books in the database. 
     
    17861796    # Then hook it into the Book model explicitly. 
    17871797    class Book(models.Model): 
    1788         title = models.CharField(maxlength=100) 
    1789         author = models.CharField(maxlength=50) 
     1798        title = models.CharField(max_length=100) 
     1799        author = models.CharField(max_length=50) 
    17901800 
    17911801        objects = models.Manager() # The default manager. 
     
    18201830 
    18211831    class Person(models.Model): 
    1822         first_name = models.CharField(maxlength=50) 
    1823         last_name = models.CharField(maxlength=50) 
    1824         sex = models.CharField(maxlength=1, choices=(('M', 'Male'), ('F', 'Female'))) 
     1832        first_name = models.CharField(max_length=50) 
     1833        last_name = models.CharField(max_length=50) 
     1834        sex = models.CharField(max_length=1, choices=(('M', 'Male'), ('F', 'Female'))) 
    18251835        people = models.Manager() 
    18261836        men = MaleManager() 
     
    18521862 
    18531863    class Person(models.Model): 
    1854         first_name = models.CharField(maxlength=50) 
    1855         last_name = models.CharField(maxlength=50) 
     1864        first_name = models.CharField(max_length=50) 
     1865        last_name = models.CharField(max_length=50) 
    18561866        birth_date = models.DateField() 
    1857         address = models.CharField(maxlength=100) 
    1858         city = models.CharField(maxlength=50) 
     1867        address = models.CharField(max_length=100) 
     1868        city = models.CharField(max_length=50) 
    18591869        state = models.USStateField() # Yes, this is America-centric... 
    18601870 
     
    18981908 
    18991909    class Person(models.Model): 
    1900         first_name = models.CharField(maxlength=50) 
    1901         last_name = models.CharField(maxlength=50) 
     1910        first_name = models.CharField(max_length=50) 
     1911        last_name = models.CharField(max_length=50) 
    19021912 
    19031913        def __str__(self): 
     
    19161926 
    19171927    class Person(models.Model): 
    1918         first_name = models.CharField(maxlength=50) 
    1919         last_name = models.CharField(maxlength=50) 
     1928        first_name = models.CharField(max_length=50) 
     1929        last_name = models.CharField(max_length=50) 
    19201930 
    19211931        def __unicode__(self): 
     
    19431953``get_absolute_url()``. 
    19441954 
    1945 Also, a couple of other bits of Django, such as the syndication-feed framework
     1955Also, a couple of other bits of Django, such as the `syndication feed framework`_
    19461956use ``get_absolute_url()`` as a convenience to reward people who've defined the 
    19471957method. 
     1958 
     1959.. syndication feed framework: ../syndication_feeds/ 
    19481960 
    19491961It's good practice to use ``get_absolute_url()`` in templates, instead of 
     
    20572069 
    20582070    class Blog(models.Model): 
    2059         name = models.CharField(maxlength=100) 
     2071        name = models.CharField(max_length=100) 
    20602072        tagline = models.TextField() 
    20612073 
     
    20682080 
    20692081    class Blog(models.Model): 
    2070         name = models.CharField(maxlength=100) 
     2082        name = models.CharField(max_length=100) 
    20712083        tagline = models.TextField() 
    20722084 
  • django/branches/schema-evolution/docs/newforms.txt

    r5734 r5822  
    642642like this:: 
    643643 
    644     <form method="post"
     644    <form method="post" action=""
    645645    <table>{{ form }}</table> 
    646646    <input type="submit" /> 
     
    654654The following is equivalent but a bit more explicit:: 
    655655 
    656     <form method="post"
     656    <form method="post" action=""
    657657    <table>{{ form.as_table }}</table> 
    658658    <input type="submit" /> 
     
    676676``{% for field in form %}``. For example:: 
    677677 
    678     <form method="post"
     678    <form method="post" action=""
    679679    <dl> 
    680680    {% for field in form %} 
     
    697697For example:: 
    698698 
    699     <form method="post"
     699    <form method="post" action=""
    700700    <ul class="myformclass"> 
    701701        <li>{{ form.sender.label }} {{ form.sender }}</li> 
     
    710710    </ul> 
    711711    </form> 
     712 
     713Binding uploaded files to a form 
     714-------------------------------- 
     715 
     716**New in Django development version** 
     717 
     718Dealing with forms that have ``FileField`` and ``ImageField`` fields 
     719is a little more complicated than a normal form. 
     720 
     721Firstly, in order to upload files, you'll need to make sure that your 
     722``<form>`` element correctly defines the ``enctype`` as 
     723``"multipart/form-data"``:: 
     724 
     725  <form enctype="multipart/form-data" method="post" action="/foo/"> 
     726 
     727Secondly, when you use the form, you need to bind the file data. File 
     728data is handled separately to normal form data, so when your form 
     729contains a ``FileField`` and ``ImageField``, you will need to specify 
     730a second argument when you bind your form. So if we extend our 
     731ContactForm to include an ``ImageField`` called ``mugshot``, we 
     732need to bind the file data containing the mugshot image:: 
     733 
     734    # Bound form with an image field 
     735    >>> data = {'subject': 'hello', 
     736    ...         'message': 'Hi there', 
     737    ...         'sender': 'foo@example.com', 
     738    ...         'cc_myself': True} 
     739    >>> file_data = {'mugshot': {'filename':'face.jpg' 
     740    ...                          'content': <file data>}} 
     741    >>> f = ContactFormWithMugshot(data, file_data) 
     742 
     743In practice, you will usually specify ``request.FILES`` as the source 
     744of file data (just like you use ``request.POST`` as the source of 
     745form data):: 
     746 
     747    # Bound form with an image field, data from the request 
     748    >>> f = ContactFormWithMugshot(request.POST, request.FILES) 
     749 
     750Constructing an unbound form is the same as always -- just omit both 
     751form data *and* file data: 
     752 
     753    # Unbound form with a image field 
     754    >>> f = ContactFormWithMugshot() 
    712755 
    713756Subclassing forms 
     
    11001143given length. 
    11011144 
     1145``FileField`` 
     1146~~~~~~~~~~~~~ 
     1147 
     1148**New in Django development version** 
     1149 
     1150    * Default widget: ``FileInput`` 
     1151    * Empty value: ``None`` 
     1152    * Normalizes to: An ``UploadedFile`` object that wraps the file content 
     1153      and file name into a single object. 
     1154    * Validates that non-empty file data has been bound to the form. 
     1155 
     1156An ``UploadedFile`` object has two attributes: 
     1157 
     1158    ======================  ===================================================== 
     1159    Argument                Description 
     1160    ======================  ===================================================== 
     1161    ``filename``            The name of the file, provided by the uploading 
     1162                            client. 
     1163    ``content``             The array of bytes comprising the file content. 
     1164    ======================  ===================================================== 
     1165 
     1166The string representation of an ``UploadedFile`` is the same as the filename 
     1167attribute. 
     1168 
     1169When you use a ``FileField`` on a form, you must also remember to 
     1170`bind the file data to the form`_. 
     1171 
     1172.. _`bind the file data to the form`: `Binding uploaded files to a form`_ 
     1173 
     1174``ImageField`` 
     1175~~~~~~~~~~~~~~ 
     1176 
     1177**New in Django development version** 
     1178 
     1179    * Default widget: ``FileInput`` 
     1180    * Empty value: ``None`` 
     1181    * Normalizes to: An ``UploadedFile`` object that wraps the file content 
     1182      and file name into a single object. 
     1183    * Validates that file data has been bound to the form, and that the 
     1184      file is of an image format understood by PIL. 
     1185 
     1186Using an ImageField requires that the `Python Imaging Library`_ is installed. 
     1187 
     1188When you use a ``FileField`` on a form, you must also remember to 
     1189`bind the file data to the form`_. 
     1190 
     1191.. _Python Imaging Library: http://www.pythonware.com/products/pil/ 
     1192 
    11021193``IntegerField`` 
    11031194~~~~~~~~~~~~~~~~ 
     
    12231314Form validation happens when the data is cleaned. If you want to customise 
    12241315this process, there are various places you can change, each one serving a 
    1225 different purpose. Thee types of cleaning methods are run during form 
     1316different purpose. Three types of cleaning methods are run during form 
    12261317processing. These are normally executed when you call the ``is_valid()`` 
    12271318method on a form. There are other things that can trigger cleaning and 
     
    13731464    ``BooleanField``                 ``BooleanField`` 
    13741465    ``CharField``                    ``CharField`` with ``max_length`` set to 
    1375                                      the model field's ``maxlength`` 
     1466                                     the model field's ``max_length`` 
    13761467    ``CommaSeparatedIntegerField``   ``CharField`` 
    13771468    ``DateField``                    ``DateField`` 
     
    13791470    ``DecimalField``                 ``DecimalField`` 
    13801471    ``EmailField``                   ``EmailField`` 
    1381     ``FileField``                    ``CharField`` 
     1472    ``FileField``                    ``FileField`` 
    13821473    ``FilePathField``                ``CharField`` 
    13831474    ``FloatField``                   ``FloatField`` 
    13841475    ``ForeignKey``                   ``ModelChoiceField`` (see below) 
    1385     ``ImageField``                   ``CharField`` 
     1476    ``ImageField``                   ``ImageField`` 
    13861477    ``IntegerField``                 ``IntegerField`` 
    13871478    ``IPAddressField``               ``CharField`` 
     
    14531544 
    14541545    class Author(models.Model): 
    1455         name = models.CharField(maxlength=100) 
    1456         title = models.CharField(maxlength=3, choices=TITLE_CHOICES) 
     1546        name = models.CharField(max_length=100) 
     1547        title = models.CharField(max_length=3, choices=TITLE_CHOICES) 
    14571548        birth_date = models.DateField(blank=True, null=True) 
    14581549 
     
    14611552 
    14621553    class Book(models.Model): 
    1463         name = models.CharField(maxlength=100) 
     1554        name = models.CharField(max_length=100) 
    14641555        authors = models.ManyToManyField(Author) 
    14651556 
     
    15031594object before saving it. ``commit`` is ``True`` by default. 
    15041595 
     1596Another side effect of using ``commit=False`` is seen when your model has 
     1597a many-to-many relation with another model. If your model has a many-to-many 
     1598relation and you specify ``commit=False`` when you save a form, Django cannot 
     1599immediately save the form data for the many-to-many relation. This is because 
     1600it isn't possible to save many-to-many data for an instance until the instance 
     1601exists in the database. 
     1602 
     1603To work around this problem, every time you save a form using ``commit=False``, 
     1604Django adds a ``save_m2m()`` method to the form created by ``form_for_model``. 
     1605After you've manually saved the instance produced by the form, you can invoke 
     1606``save_m2m()`` to save the many-to-many form data. For example:: 
     1607 
     1608    # Create a form instance with POST data. 
     1609    >>> f = AuthorForm(request.POST) 
     1610 
     1611    # Create, but don't save the new author instance. 
     1612    >>> new_author = f.save(commit=False) 
     1613 
     1614    # Modify the author in some way. 
     1615    >>> new_author.some_field = 'some_value' 
     1616 
     1617    # Save the new instance. 
     1618    >>> new_author.save() 
     1619 
     1620    # Now, save the many-to-many data for the form. 
     1621    >>> f.save_m2m() 
     1622 
     1623Calling ``save_m2m()`` is only required if you use ``save(commit=False)``. 
     1624When you use a simple ``save()`` on a form, all data -- including 
     1625many-to-many data -- is saved without the need for any additional method calls. 
     1626For example:: 
     1627 
     1628        # Create a form instance with POST data. 
     1629        >>> f = AuthorForm(request.POST) 
     1630 
     1631    # Create and save the new author instance. There's no need to do anything else. 
     1632    >>> new_author = f.save() 
     1633 
    15051634Using an alternate base class 
    15061635~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • django/branches/schema-evolution/docs/overview.txt

    r5734 r5822  
    2626 
    2727    class Reporter(models.Model): 
    28         full_name = models.CharField(maxlength=70) 
     28        full_name = models.CharField(max_length=70) 
    2929 
    3030        def __unicode__(self): 
     
    3333    class Article(models.Model): 
    3434        pub_date = models.DateTimeField() 
    35         headline = models.CharField(maxlength=200) 
     35        headline = models.CharField(max_length=200) 
    3636        article = models.TextField() 
    3737        reporter = models.ForeignKey(Reporter) 
     
    135135    class Article(models.Model): 
    136136        pub_date = models.DateTimeField() 
    137         headline = models.CharField(maxlength=200) 
     137        headline = models.CharField(max_length=200) 
    138138        article = models.TextField() 
    139139        reporter = models.ForeignKey(Reporter) 
     
    289289 
    290290    * A caching framework that integrates with memcached or other backends. 
    291     * A syndication framework that makes creating RSS and Atom feeds as easy as 
     291    * A `syndication framework`_ that makes creating RSS and Atom feeds as easy as 
    292292      writing a small Python class. 
    293293    * More sexy automatically-generated admin features -- this overview barely 
    294294      scratched the surface. 
    295295 
     296.. _syndication framework: ../syndication_feeds/ 
     297 
    296298The next obvious steps are for you to `download Django`_, read `the tutorial`_ 
    297299and join `the community`_. Thanks for your interest! 
    298300 
    299301.. _download Django: http://www.djangoproject.com/download/ 
    300 .. _the tutorial: http://www.djangoproject.com/documentation/tutorial01/ 
     302.. _the tutorial: ../tutorial01/ 
    301303.. _the community: http://www.djangoproject.com/community/ 
  • django/branches/schema-evolution/docs/release_notes_0.95.txt

    r3937 r5822  
    115115available at any hour of the day -- to help, or just to chat. 
    116116 
    117 .. _online: http://www.djangoproject.com/documentation/ 
     117.. _online: http://www.djangoproject.com/documentation/0.95/ 
    118118.. _Django website: http://www.djangoproject.com/ 
    119119.. _FAQ: http://www.djangoproject.com/documentation/faq/ 
  • django/branches/schema-evolution/docs/request_response.txt

    r5734 r5822  
    298298is responsible for instantiating, populating and returning an ``HttpResponse``. 
    299299 
    300 The ``HttpResponse`` class lives at ``django.http.HttpResponse``
     300The ``HttpResponse`` class lives in the ``django.http`` module
    301301 
    302302Usage 
  • django/branches/schema-evolution/docs/sitemaps.txt

    r5734 r5822  
    2222write a ``Sitemap`` class and point to it in your URLconf_. 
    2323 
    24 .. _syndication framework: ../syndication
     24.. _syndication framework: ../syndication_feeds
    2525.. _URLconf: ../url_dispatch/ 
    2626 
  • django/branches/schema-evolution/docs/sites.txt

    r5734 r5822  
    4747 
    4848    class Article(models.Model): 
    49         headline = models.CharField(maxlength=200) 
     49        headline = models.CharField(max_length=200) 
    5050        # ... 
    5151        sites = models.ManyToManyField(Site) 
     
    8888 
    8989    class Article(models.Model): 
    90         headline = models.CharField(maxlength=200) 
     90        headline = models.CharField(max_length=200) 
    9191        # ... 
    9292        site = models.ForeignKey(Site) 
     
    230230    class Photo(models.Model): 
    231231        photo = models.FileField(upload_to='/home/photos') 
    232         photographer_name = models.CharField(maxlength=100) 
     232        photographer_name = models.CharField(max_length=100) 
    233233        pub_date = models.DateField() 
    234234        site = models.ForeignKey(Site) 
     
    258258    class Photo(models.Model): 
    259259        photo = models.FileField(upload_to='/home/photos') 
    260         photographer_name = models.CharField(maxlength=100) 
     260        photographer_name = models.CharField(max_length=100) 
    261261