diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-12-19 05:08:37 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-12-19 05:08:37 +0000 |
| commit | 97091940b1efbc6018133e9f77402c2983fa702f (patch) | |
| tree | e003a3ec00ab4b0bd0cda7799485cedbf787cd31 /docs/custom_model_fields.txt | |
| parent | 13d3162aaf7fce11c06d447f397e32b7648ae199 (diff) | |
queryset-refactor: Merged from trunk up to [6953].
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6954 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/custom_model_fields.txt')
| -rw-r--r-- | docs/custom_model_fields.txt | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/docs/custom_model_fields.txt b/docs/custom_model_fields.txt index 0cf2549746..923b331a95 100644 --- a/docs/custom_model_fields.txt +++ b/docs/custom_model_fields.txt @@ -44,8 +44,8 @@ Our class looks something like this:: # ... (other possibly useful methods omitted) ... This is just an ordinary Python class, with nothing Django-specific about it. -We'd like to be able to things like this in our models (we assume the ``hand`` -attribute on the model is an instance of ``Hand``):: +We'd like to be able to do things like this in our models (we assume the +``hand`` attribute on the model is an instance of ``Hand``):: example = MyModel.objects.get(pk=1) print example.hand.north @@ -382,6 +382,10 @@ database, so we need to be able to process strings and ``Hand`` instances in Notice that we always return a ``Hand`` instance from this method. That's the Python object type we want to store in the model's attribute. +**Remember:** If your custom field needs the ``to_python()`` method to be +called when it is created, you should be using `The SubfieldBase metaclass`_ +mentioned earlier. Otherwise ``to_python()`` won't be called automatically. + ``get_db_prep_save(self, value)`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
