mirror of https://github.com/django/django.git
Made cosmetic cleanups to docs/ref/contrib/contenttypes.txt
This commit is contained in:
parent
8d1a001ef6
commit
b47552b445
|
@ -98,8 +98,6 @@ created with the following values:
|
||||||
* :attr:`~django.contrib.contenttypes.models.ContentType.model`
|
* :attr:`~django.contrib.contenttypes.models.ContentType.model`
|
||||||
will be set to ``'site'``.
|
will be set to ``'site'``.
|
||||||
|
|
||||||
.. _the verbose_name attribute: ../model-api/#verbose_name
|
|
||||||
|
|
||||||
Methods on ``ContentType`` instances
|
Methods on ``ContentType`` instances
|
||||||
====================================
|
====================================
|
||||||
|
|
||||||
|
@ -126,8 +124,7 @@ For example, we could look up the
|
||||||
:class:`~django.contrib.auth.models.User` model::
|
:class:`~django.contrib.auth.models.User` model::
|
||||||
|
|
||||||
>>> from django.contrib.contenttypes.models import ContentType
|
>>> from django.contrib.contenttypes.models import ContentType
|
||||||
>>> user_type = ContentType.objects.get(app_label="auth", model="user")
|
>>> ContentType.objects.get(app_label="auth", model="user")
|
||||||
>>> user_type
|
|
||||||
<ContentType: user>
|
<ContentType: user>
|
||||||
|
|
||||||
And then use it to query for a particular
|
And then use it to query for a particular
|
||||||
|
@ -224,8 +221,7 @@ want to go to the trouble of obtaining the model's metadata to perform a manual
|
||||||
lookup::
|
lookup::
|
||||||
|
|
||||||
>>> from django.contrib.auth.models import User
|
>>> from django.contrib.auth.models import User
|
||||||
>>> user_type = ContentType.objects.get_for_model(User)
|
>>> ContentType.objects.get_for_model(User)
|
||||||
>>> user_type
|
|
||||||
<ContentType: user>
|
<ContentType: user>
|
||||||
|
|
||||||
.. module:: django.contrib.contenttypes.fields
|
.. module:: django.contrib.contenttypes.fields
|
||||||
|
@ -369,6 +365,9 @@ Reverse generic relations
|
||||||
If you know which models you'll be using most often, you can also add
|
If you know which models you'll be using most often, you can also add
|
||||||
a "reverse" generic relationship to enable an additional API. For example::
|
a "reverse" generic relationship to enable an additional API. For example::
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
from django.contrib.contenttypes.fields import GenericRelation
|
||||||
|
|
||||||
class Bookmark(models.Model):
|
class Bookmark(models.Model):
|
||||||
url = models.URLField()
|
url = models.URLField()
|
||||||
tags = GenericRelation(TaggedItem)
|
tags = GenericRelation(TaggedItem)
|
||||||
|
@ -464,7 +463,6 @@ to the queryset to ensure the correct content type, but the
|
||||||
into account. For now, if you need aggregates on generic relations, you'll
|
into account. For now, if you need aggregates on generic relations, you'll
|
||||||
need to calculate them without using the aggregation API.
|
need to calculate them without using the aggregation API.
|
||||||
|
|
||||||
|
|
||||||
.. module:: django.contrib.contenttypes.forms
|
.. module:: django.contrib.contenttypes.forms
|
||||||
|
|
||||||
Generic relation in forms
|
Generic relation in forms
|
||||||
|
|
Loading…
Reference in New Issue