Ticket #13184: 13184-doc.diff

File 13184-doc.diff, 914 bytes (added by Honza Král, 15 years ago)

Alternative solution to the problem - documenting how to handle custom fields' formfield method

  • docs/howto/custom-model-fields.txt

    diff --git a/docs/howto/custom-model-fields.txt b/docs/howto/custom-model-fields.txt
    index 169f511..31ee331 100644
    a b For example::  
    261261This ensures that the :meth:`to_python` method, documented below, will always be
    262262called when the attribute is initialized.
    263263
     264.. note::
     265    Since :meth:`to_python` method is being called every time the attribute is
     266    assigned a value you need to make sure that it is always initialized with
     267    the correct datatype or that you handle any potential exceptions. This is
     268    most important when working with :ref:`ModelForms <topics-forms-modelforms>`.
     269    To make sure that is so you need to implement the :meth:`formfield` method
     270    to return a field class whose `to_python` returns the correct datatype.
     271
    264272
    265273Documenting your Custom Field
    266274-----------------------------
Back to Top