86 | | == How do I extend a model? I want to subclass django.contrib.auth.models.User. == #ModelSubclassing |
87 | | |
88 | | This feature has been added to the queryset-refactoring branch, but it is not available in either the trunk or a numbered release yet. Specific instructions for the User model can be found at http://www.b-list.org/weblog/2007/02/20/about-model-subclassing and http://www.djangobook.com/en/beta/chapter12/#cn226 |
| 86 | == How do I create a subclass of an existing model? == #ModelInheritance |
| 87 | |
| 88 | Model inheritance (aka model subclassing) is available in Django trunk as of r7477. |
| 89 | |
| 90 | If you're using it, make sure you've [http://www.djangoproject.com/documentation/model-api/#model-inheritance read the documentation] and understand the difference between '''abstract base class''' and '''multi-table''' inheritance options. The latter can be confusing to newcomers because an instance of a parent class will also contain, on an attribute named after a child class, that same object represented as an instance of the child class. Got that? |
| 91 | |
| 92 | An established mechanism for adding additional information to Django `User` objects without subclassing is known as "profiles"; you can [http://www.djangobook.com/en/1.0/chapter12/#s-profiles read about it in the Definitive Guide]. |
| 93 | |
| 94 | For an important alternatve viewpoint on model subclassing, see: http://www.b-list.org/weblog/2007/02/20/about-model-subclassing |