subfieldbase not in django core fields

3 views
Skip to first unread message

Daniel Vainsencher Maya Monteiro

unread,
Jun 29, 2009, 2:48:15 PM6/29/09
to django-d...@googlegroups.com
Why does subclassing model field requirement[1] for custom fields is
not applied to django core fields?

[1] http://tinyurl.com/l2lvbx

Any Django field classes has SubfieldBase metaclass declared, so for
an "initial" DateField attribute:

>>> ob = MyModel.objects.create(type=1,initial='2009-01-01')
>>> ob.initial
'2009-01-01'

when I set SubfieldBase metaclass for
django.db.models.fields.DateField as stated in documentation i have:

>>> ob = MyModel.objects.create(type=1,initial='2009-01-01')
>>> ob.initial
datetime.date(2009, 1, 1)

as expected, the to_python method convert the string to a date type.

Thanks!

daniel

Reply all
Reply to author
Forward
0 new messages