Ticket #16000: natural_keys_in_contenttype_docs.diff
File natural_keys_in_contenttype_docs.diff, 1.9 KB (added by , 14 years ago) |
---|
-
docs/ref/contrib/contenttypes.txt
191 191 Takes either a model class or an instance of a model, and returns the 192 192 :class:`~django.contrib.contenttypes.models.ContentType` instance 193 193 representing that model. 194 195 .. method:: get_by_natural_key(app_label, model) 194 196 197 Returns the :class:`~django.contrib.contenttypes.models.ContentType` 198 instance uniquely identified by the given application label and model 199 name. The primary purpose of this method is to allow 200 :class:`~django.contrib.contenttypes.models.ContentType` objects to be 201 referenced via a :ref:`natural key<topics-serialization-natural-keys>` 202 during deserialization. 203 195 204 The :meth:`~ContentTypeManager.get_for_model()` method is especially 196 205 useful when you know you need to work with a 197 206 :class:`ContentType <django.contrib.contenttypes.models.ContentType>` but don't … … 285 294 should evaluate the models you expect to be pointing to and determine 286 295 which solution will be most effective for your use case. 287 296 297 .. admonition:: Serializing references to ``ContentType`` objects 298 299 If you're serializing data (for example, when generating 300 :class:`~django.test.TestCase.fixtures`) from a model that implements generic 301 relations, you should probably be using a natural key to uniquely identify 302 related :class:`~django.contrib.contenttypes.models.ContentType` objects. See 303 :ref:`natural keys<topics-serialization-natural-keys>` and 304 :djadminopt:`dumpdata --natural <--natural>` for more information. 305 288 306 This will enable an API similar to the one used for a normal 289 307 :class:`~django.db.models.ForeignKey`; 290 308 each ``TaggedItem`` will have a ``content_object`` field that returns the