mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #19774 -- Deprecated the contenttypes.generic module.
It contained models, forms and admin objects causing undesirable import side effects. Refs #16368. Thanks to Ramiro, Carl and Loïc for the review.
This commit is contained in:
parent
c3881944e8
commit
10e3faf191
33 changed files with 1011 additions and 906 deletions
|
@ -1,5 +1,7 @@
|
|||
# coding: utf-8
|
||||
from django.contrib.contenttypes import generic
|
||||
from django.contrib.contenttypes.fields import (
|
||||
GenericForeignKey, GenericRelation
|
||||
)
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
@ -28,7 +30,7 @@ class ItemTag(models.Model):
|
|||
tag = models.CharField(max_length=100)
|
||||
content_type = models.ForeignKey(ContentType)
|
||||
object_id = models.PositiveIntegerField()
|
||||
content_object = generic.GenericForeignKey('content_type', 'object_id')
|
||||
content_object = GenericForeignKey('content_type', 'object_id')
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
|
@ -42,7 +44,7 @@ class Book(models.Model):
|
|||
contact = models.ForeignKey(Author, related_name='book_contact_set')
|
||||
publisher = models.ForeignKey(Publisher)
|
||||
pubdate = models.DateField()
|
||||
tags = generic.GenericRelation(ItemTag)
|
||||
tags = GenericRelation(ItemTag)
|
||||
|
||||
class Meta:
|
||||
ordering = ('name',)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue