{{{
#!python
class MyCustomField(models.Field):
__metaclass__ = models.SubfieldBase
}}}
is no longer supported and that they should use:
{{{
#!python
class MyCustomField(models.Field, metaclass=models.SubfieldBase):
...
}}}
instead.
Writing in the first (old) fashion results in no errors or warnings
whatsoever. The to_python() method is just not called as it should be...
--
Ticket URL: <https://code.djangoproject.com/ticket/19539>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
The second version isn't acceptable as is because it's a syntax error
under Python 2. If you want a single snippet that works in Python 2 and 3
you have to use `six.with_metaclass`.
Currently the documentation assumes Python 2. We haven't chosen how to
document things that are different in Python 2 and 3 yet.
Technically, this ticket is valid, but it covers about 0.1% of the
problem. For starters, the docs has tons of `__unicode__` methods that
don't make any sense under Python 3...
--
Ticket URL: <https://code.djangoproject.com/ticket/19539#comment:1>
* type: Uncategorized => New feature
* stage: Unreviewed => Design decision needed
--
Ticket URL: <https://code.djangoproject.com/ticket/19539#comment:2>
* stage: Design decision needed => Accepted
Comment:
We'll have to fix this at some point.
--
Ticket URL: <https://code.djangoproject.com/ticket/19539#comment:3>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/19539#comment:4>
* type: New feature => Cleanup/optimization
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/19539#comment:5>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"b9fceadfd440daec09dee3c7c9d01997f94ec94f"]:
{{{
#!CommitTicketReference repository=""
revision="b9fceadfd440daec09dee3c7c9d01997f94ec94f"
Fixed #19539 -- Updated custom model fields example for Python 3.
Thanks astorije@ for the report.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/19539#comment:6>
Comment (by Tim Graham <timograham@…>):
In [changeset:"6c984587711f82c0fc5223bbf6e8bb3b71732a3e"]:
{{{
#!CommitTicketReference repository=""
revision="6c984587711f82c0fc5223bbf6e8bb3b71732a3e"
[1.5.x] Fixed #19539 -- Updated custom model fields example for Python 3.
Thanks astorije@ for the report.
Backport of b9fceadfd4 from master.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/19539#comment:7>
Comment (by Tim Graham <timograham@…>):
In [changeset:"14a5b79e294506ab045a14fbec89030510f1cefe"]:
{{{
#!CommitTicketReference repository=""
revision="14a5b79e294506ab045a14fbec89030510f1cefe"
[1.6.x] Fixed #19539 -- Updated custom model fields example for Python 3.
Thanks astorije@ for the report.
Backport of b9fceadfd4 from master.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/19539#comment:8>