2014-11-05 02:57:47 +00:00
|
|
|
from django.db import models
|
2015-11-17 05:39:28 +00:00
|
|
|
from django.test import SimpleTestCase
|
|
|
|
from django.test.utils import isolate_apps
|
2014-11-05 02:57:47 +00:00
|
|
|
|
|
|
|
|
2015-11-17 05:39:28 +00:00
|
|
|
@isolate_apps("invalid_models_tests")
|
|
|
|
class CustomFieldTest(SimpleTestCase):
|
2014-11-05 02:57:47 +00:00
|
|
|
def test_none_column(self):
|
|
|
|
class NoColumnField(models.AutoField):
|
|
|
|
def db_type(self, connection):
|
|
|
|
# None indicates not to create a column in the database.
|
|
|
|
return None
|
|
|
|
|
|
|
|
class Model(models.Model):
|
|
|
|
field = NoColumnField(primary_key=True, db_column="other_field")
|
|
|
|
other_field = models.IntegerField()
|
|
|
|
|
|
|
|
field = Model._meta.get_field("field")
|
2017-07-11 08:53:22 +00:00
|
|
|
self.assertEqual(field.check(), [])
|