mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Moved all the reused models to the models files to avoid conflicts with the refactored apps.
This commit is contained in:
parent
7713ddc0a8
commit
6aadd1639b
|
@ -168,3 +168,30 @@ class NullableOneToOneSource(RESTFrameworkModel):
|
||||||
class BasicModelSerializer(serializers.ModelSerializer):
|
class BasicModelSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = BasicModel
|
model = BasicModel
|
||||||
|
|
||||||
|
|
||||||
|
# Models to test the serializers
|
||||||
|
class AMOAFModel(RESTFrameworkModel):
|
||||||
|
char_field = models.CharField(max_length=1024, blank=True)
|
||||||
|
comma_separated_integer_field = models.CommaSeparatedIntegerField(max_length=1024, blank=True)
|
||||||
|
decimal_field = models.DecimalField(max_digits=64, decimal_places=32, blank=True)
|
||||||
|
email_field = models.EmailField(max_length=1024, blank=True)
|
||||||
|
file_field = models.FileField(max_length=1024, blank=True)
|
||||||
|
image_field = models.ImageField(max_length=1024, blank=True)
|
||||||
|
slug_field = models.SlugField(max_length=1024, blank=True)
|
||||||
|
url_field = models.URLField(max_length=1024, blank=True)
|
||||||
|
|
||||||
|
class DVOAFModel(RESTFrameworkModel):
|
||||||
|
positive_integer_field = models.PositiveIntegerField(blank=True)
|
||||||
|
positive_small_integer_field = models.PositiveSmallIntegerField(blank=True)
|
||||||
|
email_field = models.EmailField(blank=True)
|
||||||
|
file_field = models.FileField(blank=True)
|
||||||
|
image_field = models.ImageField(blank=True)
|
||||||
|
slug_field = models.SlugField(blank=True)
|
||||||
|
url_field = models.URLField(blank=True)
|
||||||
|
|
||||||
|
# Models to test filters
|
||||||
|
class FilterableItem(models.Model):
|
||||||
|
text = models.CharField(max_length=100)
|
||||||
|
decimal = models.DecimalField(max_digits=4, decimal_places=2)
|
||||||
|
date = models.DateField()
|
||||||
|
|
|
@ -9,16 +9,11 @@ from rest_framework import generics, serializers, status, filters
|
||||||
from rest_framework.compat import django_filters, patterns, url
|
from rest_framework.compat import django_filters, patterns, url
|
||||||
from rest_framework.test import APIRequestFactory
|
from rest_framework.test import APIRequestFactory
|
||||||
from rest_framework.tests.models import BasicModel
|
from rest_framework.tests.models import BasicModel
|
||||||
|
from .models import FilterableItem
|
||||||
|
|
||||||
factory = APIRequestFactory()
|
factory = APIRequestFactory()
|
||||||
|
|
||||||
|
|
||||||
class FilterableItem(models.Model):
|
|
||||||
text = models.CharField(max_length=100)
|
|
||||||
decimal = models.DecimalField(max_digits=4, decimal_places=2)
|
|
||||||
date = models.DateField()
|
|
||||||
|
|
||||||
|
|
||||||
if django_filters:
|
if django_filters:
|
||||||
# Basic filter on a list view.
|
# Basic filter on a list view.
|
||||||
class FilterFieldsRootView(generics.ListCreateAPIView):
|
class FilterFieldsRootView(generics.ListCreateAPIView):
|
||||||
|
|
|
@ -9,16 +9,11 @@ from rest_framework import generics, status, pagination, filters, serializers
|
||||||
from rest_framework.compat import django_filters
|
from rest_framework.compat import django_filters
|
||||||
from rest_framework.test import APIRequestFactory
|
from rest_framework.test import APIRequestFactory
|
||||||
from rest_framework.tests.models import BasicModel
|
from rest_framework.tests.models import BasicModel
|
||||||
|
from .models import FilterableItem
|
||||||
|
|
||||||
factory = APIRequestFactory()
|
factory = APIRequestFactory()
|
||||||
|
|
||||||
|
|
||||||
class FilterableItem(models.Model):
|
|
||||||
text = models.CharField(max_length=100)
|
|
||||||
decimal = models.DecimalField(max_digits=4, decimal_places=2)
|
|
||||||
date = models.DateField()
|
|
||||||
|
|
||||||
|
|
||||||
class RootView(generics.ListCreateAPIView):
|
class RootView(generics.ListCreateAPIView):
|
||||||
"""
|
"""
|
||||||
Example description for OPTIONS.
|
Example description for OPTIONS.
|
||||||
|
|
|
@ -3,9 +3,7 @@ from django.db import models
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from .models import OneToOneTarget
|
||||||
class OneToOneTarget(models.Model):
|
|
||||||
name = models.CharField(max_length=100)
|
|
||||||
|
|
||||||
|
|
||||||
class OneToOneSource(models.Model):
|
class OneToOneSource(models.Model):
|
||||||
|
|
|
@ -8,7 +8,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||||
from rest_framework import serializers, fields, relations
|
from rest_framework import serializers, fields, relations
|
||||||
from rest_framework.tests.models import (HasPositiveIntegerAsChoice, Album, ActionItem, Anchor, BasicModel,
|
from rest_framework.tests.models import (HasPositiveIntegerAsChoice, Album, ActionItem, Anchor, BasicModel,
|
||||||
BlankFieldModel, BlogPost, BlogPostComment, Book, CallableDefaultValueModel, DefaultValueModel,
|
BlankFieldModel, BlogPost, BlogPostComment, Book, CallableDefaultValueModel, DefaultValueModel,
|
||||||
ManyToManyModel, Person, ReadOnlyManyToManyModel, Photo, RESTFrameworkModel)
|
ManyToManyModel, Person, ReadOnlyManyToManyModel, Photo, RESTFrameworkModel, AMOAFModel, DVOAFModel)
|
||||||
from rest_framework.tests.models import BasicModelSerializer
|
from rest_framework.tests.models import BasicModelSerializer
|
||||||
import datetime
|
import datetime
|
||||||
import pickle
|
import pickle
|
||||||
|
@ -1481,15 +1481,6 @@ class ManyFieldHelpTextTest(TestCase):
|
||||||
class AttributeMappingOnAutogeneratedFieldsTests(TestCase):
|
class AttributeMappingOnAutogeneratedFieldsTests(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
class AMOAFModel(RESTFrameworkModel):
|
|
||||||
char_field = models.CharField(max_length=1024, blank=True)
|
|
||||||
comma_separated_integer_field = models.CommaSeparatedIntegerField(max_length=1024, blank=True)
|
|
||||||
decimal_field = models.DecimalField(max_digits=64, decimal_places=32, blank=True)
|
|
||||||
email_field = models.EmailField(max_length=1024, blank=True)
|
|
||||||
file_field = models.FileField(max_length=1024, blank=True)
|
|
||||||
image_field = models.ImageField(max_length=1024, blank=True)
|
|
||||||
slug_field = models.SlugField(max_length=1024, blank=True)
|
|
||||||
url_field = models.URLField(max_length=1024, blank=True)
|
|
||||||
|
|
||||||
class AMOAFSerializer(serializers.ModelSerializer):
|
class AMOAFSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -1562,14 +1553,6 @@ class AttributeMappingOnAutogeneratedFieldsTests(TestCase):
|
||||||
class DefaultValuesOnAutogeneratedFieldsTests(TestCase):
|
class DefaultValuesOnAutogeneratedFieldsTests(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
class DVOAFModel(RESTFrameworkModel):
|
|
||||||
positive_integer_field = models.PositiveIntegerField(blank=True)
|
|
||||||
positive_small_integer_field = models.PositiveSmallIntegerField(blank=True)
|
|
||||||
email_field = models.EmailField(blank=True)
|
|
||||||
file_field = models.FileField(blank=True)
|
|
||||||
image_field = models.ImageField(blank=True)
|
|
||||||
slug_field = models.SlugField(blank=True)
|
|
||||||
url_field = models.URLField(blank=True)
|
|
||||||
|
|
||||||
class DVOAFSerializer(serializers.ModelSerializer):
|
class DVOAFSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user