mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +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:
@@ -1,6 +1,8 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
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, connection
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
@@ -46,13 +48,13 @@ class Tag(models.Model):
|
||||
name = models.CharField(max_length=30)
|
||||
content_type = models.ForeignKey(ContentType, related_name='backend_tags')
|
||||
object_id = models.PositiveIntegerField()
|
||||
content_object = generic.GenericForeignKey('content_type', 'object_id')
|
||||
content_object = GenericForeignKey('content_type', 'object_id')
|
||||
|
||||
|
||||
class Post(models.Model):
|
||||
name = models.CharField(max_length=30)
|
||||
text = models.TextField()
|
||||
tags = generic.GenericRelation('Tag')
|
||||
tags = GenericRelation('Tag')
|
||||
|
||||
class Meta:
|
||||
db_table = 'CaseSensitive_Post'
|
||||
|
||||
Reference in New Issue
Block a user