mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-30 18:09:59 +03:00
Removed repeated model in tests and isort fix
This commit is contained in:
parent
c2c11a535f
commit
9e36a84619
|
@ -1,46 +1,8 @@
|
|||
from django.contrib.contenttypes.fields import (
|
||||
GenericForeignKey, GenericRelation
|
||||
)
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import models
|
||||
from django.test import TestCase
|
||||
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
class Tag(models.Model):
|
||||
"""
|
||||
Tags have a descriptive slug, and are attached to an arbitrary object.
|
||||
"""
|
||||
tag = models.SlugField()
|
||||
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
|
||||
object_id = models.PositiveIntegerField()
|
||||
tagged_item = GenericForeignKey('content_type', 'object_id')
|
||||
|
||||
def __str__(self):
|
||||
return self.tag
|
||||
|
||||
|
||||
class Bookmark(models.Model):
|
||||
"""
|
||||
A URL bookmark that may have multiple tags attached.
|
||||
"""
|
||||
url = models.URLField()
|
||||
tags = GenericRelation(Tag)
|
||||
|
||||
def __str__(self):
|
||||
return 'Bookmark: %s' % self.url
|
||||
|
||||
|
||||
class Note(models.Model):
|
||||
"""
|
||||
A textual note that may have multiple tags attached.
|
||||
"""
|
||||
text = models.TextField()
|
||||
tags = GenericRelation(Tag)
|
||||
|
||||
def __str__(self):
|
||||
return 'Note: %s' % self.text
|
||||
from .models import Bookmark, Note, Tag
|
||||
|
||||
|
||||
class TestGenericRelations(TestCase):
|
||||
|
|
|
@ -8,6 +8,7 @@ from django.contrib.auth.models import AnonymousUser, Group, Permission, User
|
|||
from django.db import models
|
||||
from django.test import TestCase
|
||||
from django.urls import ResolverMatch
|
||||
from tests.models import BasicModel
|
||||
|
||||
from rest_framework import (
|
||||
HTTP_HEADER_ENCODING, RemovedInDRF310Warning, authentication, generics,
|
||||
|
@ -18,8 +19,6 @@ from rest_framework.filters import DjangoObjectPermissionsFilter
|
|||
from rest_framework.routers import DefaultRouter
|
||||
from rest_framework.test import APIRequestFactory
|
||||
|
||||
from tests.models import BasicModel
|
||||
|
||||
factory = APIRequestFactory()
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.conf.urls import url
|
||||
from django.test import TestCase, override_settings
|
||||
from tests.models import BasicModel
|
||||
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.routers import SimpleRouter
|
||||
|
@ -10,8 +11,6 @@ from rest_framework.utils.urls import remove_query_param, replace_query_param
|
|||
from rest_framework.views import APIView
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
from tests.models import BasicModel
|
||||
|
||||
|
||||
class Root(APIView):
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue
Block a user