Changes between Version 2 and Version 3 of ModelSyntaxChangeInstructions


Ignore:
Timestamp:
Aug 25, 2005, 3:06:40 PM (19 years ago)
Author:
Adrian Holovaty
Comment:

Some bug fixes and clarifications.

Legend:

Unmodified
Added
Removed
Modified
  • ModelSyntaxChangeInstructions

    v2 v3  
    1 == Django model syntax change ==
     1= Django model syntax change =
    22
    33As of ____, Django's model syntax has changed. If you're using models that use old (pre-____) syntax, you'll need to convert them according to the these instructions.
    44
    5 === What changed ===
     5== What changed ==
    66
    77 * Fields are now attributes of the model class, rather than members of a {{{fields}}} list.
     
    1111 * {{{rel_name}}} is no longer used for {{{ManyToManyField}}}s. If your model has more than one {{{ManyToManyField}}} to the same foreign model, differentiate the fields using the field name, not {{{rel_name}}}. Also, give both of the {{{ManyToManyField}}}s a {{{singular}}} attribute, which defines the name of the related object in singular format. (This is an obscure case, but it's included here for completeness.)
    1212
    13 === Examples ===
     13== Examples ==
    1414
    15 Old syntax example:
     15=== Old syntax example ===
    1616
    1717{{{
     
    1919class Foo(meta.Model):
    2020    fields = (
    21         meta.CharField('first_name', maxlength=30),
     21        meta.CharField('first_name', "The person's first name", maxlength=30),
    2222        meta.CharField('last_name', maxlength=30),
    2323        meta.ForeignKey(Bar),
     
    3232}}}
    3333
    34 New syntax example:
     34=== New syntax example ===
    3535
    3636{{{
    3737#!python
    3838class Foo(meta.Model):
    39     first_name = meta.CharField('first_name', maxlength=30)
    40     last_name = meta.CharField('last_name', maxlength=30)
     39    first_name = meta.CharField("The person's first name", maxlength=30)
     40    last_name = meta.CharField(maxlength=30)
    4141    bar = meta.ForeignKey(Bar)
    4242    sites = meta.ManyToManyField(Sites)
     
    5454 * {{{bar}}} and {{{sites}}} now have explicit names, and {{{admin.fields}}} was changed to use {{{bar}}} instead of {{{bar_id}}}.
    5555 * {{{ordering}}} was also changed to use the explicit name {{{bar}}} instead of {{{bar_id}}}.
     56 * The {{{verbose_name}}} is now an optional first argument to {{{Field}}}s. For {{{ForeignKey}}}s, {{{ManyToManyField}}}s and {{{OneToOneField}}}s, use a named argument: {{{verbose_name="foo"}}}.
    5657 * Don't forget to remove the commas after each {{{Field}}}, because they're class attributes instead of list elements now.
Back to Top