commit
758eb577e4
|
|
@ -3,7 +3,7 @@
|
||||||
Please see README.rst or DOCS.rst or http://bserve.webhop.org/wiki/django_polymorphic
|
Please see README.rst or DOCS.rst or http://bserve.webhop.org/wiki/django_polymorphic
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import settings
|
from django.conf import settings
|
||||||
import sys
|
import sys
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
|
|
@ -582,7 +582,7 @@ __test__ = {"doctest": """
|
||||||
>>> type(ModelWithMyManager.objects)
|
>>> type(ModelWithMyManager.objects)
|
||||||
<class 'polymorphic.tests.MyManager'>
|
<class 'polymorphic.tests.MyManager'>
|
||||||
>>> type(ModelWithMyManager._default_manager)
|
>>> type(ModelWithMyManager._default_manager)
|
||||||
<class 'polymorphic.tests.MyManager'>
|
<class 'polymorphic.manager.PolymorphicManager'>
|
||||||
|
|
||||||
|
|
||||||
### Manager Inheritance
|
### Manager Inheritance
|
||||||
|
|
@ -592,11 +592,11 @@ __test__ = {"doctest": """
|
||||||
|
|
||||||
# check for correct default manager
|
# check for correct default manager
|
||||||
>>> type(MROBase1._default_manager)
|
>>> type(MROBase1._default_manager)
|
||||||
<class 'polymorphic.tests.MyManager'>
|
<class 'polymorphic.manager.PolymorphicManager'>
|
||||||
|
|
||||||
# Django vanilla inheritance does not inherit MyManager as _default_manager here
|
# Django vanilla inheritance does not inherit MyManager as _default_manager here
|
||||||
>>> type(MROBase2._default_manager)
|
>>> type(MROBase2._default_manager)
|
||||||
<class 'polymorphic.tests.MyManager'>
|
<class 'polymorphic.manager.PolymorphicManager'>
|
||||||
|
|
||||||
|
|
||||||
### fixed issue in PolymorphicModel.__getattribute__: field name same as model name
|
### fixed issue in PolymorphicModel.__getattribute__: field name same as model name
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,9 @@ class UUIDField(models.CharField):
|
||||||
|
|
||||||
def db_type(self, connection):
|
def db_type(self, connection):
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
return UUIDField._CREATE_COLUMN_TYPES.get(settings.DATABASE_ENGINE, "char(%s)" % self.max_length)
|
full_database_type = settings.DATABASES['default']['ENGINE']
|
||||||
|
database_type = full_database_type.split('.')[-1]
|
||||||
|
return UUIDField._CREATE_COLUMN_TYPES.get(database_type, "char(%s)" % self.max_length)
|
||||||
|
|
||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
"""Return a uuid.UUID instance from the value returned by the database."""
|
"""Return a uuid.UUID instance from the value returned by the database."""
|
||||||
|
|
|
||||||
18
settings.py
18
settings.py
|
|
@ -9,28 +9,12 @@ ADMINS = (
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
MANAGERS = ADMINS
|
||||||
|
|
||||||
import django
|
|
||||||
import os
|
|
||||||
|
|
||||||
if os.path.ismount('/ram'):
|
|
||||||
SQLITE_DB_PATH = '/ram/django-polymorphic-test-db.sqlite3'
|
|
||||||
else:
|
|
||||||
SQLITE_DB_PATH = '/var/tmp/django-polymorphic-test-db.sqlite3'
|
|
||||||
|
|
||||||
if django.VERSION[:2][0]>=1 and django.VERSION[:2][1]>=3:
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': SQLITE_DB_PATH
|
'NAME': ':memory:'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else:
|
|
||||||
DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
|
|
||||||
DATABASE_NAME = SQLITE_DB_PATH # Or path to database file if using sqlite3.
|
|
||||||
DATABASE_USER = '' # Not used with sqlite3.
|
|
||||||
DATABASE_PASSWORD = '' # Not used with sqlite3.
|
|
||||||
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
|
|
||||||
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
|
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
# Local time zone for this installation. Choices can be found here:
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
[tox]
|
||||||
|
envlist=
|
||||||
|
py26-django15,
|
||||||
|
py27-django15,
|
||||||
|
py26-django14,
|
||||||
|
py27-django14,
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
commands=
|
||||||
|
python manage.py test
|
||||||
|
|
||||||
|
# Build configurations
|
||||||
|
|
||||||
|
[testenv:py26-django15]
|
||||||
|
basepython=python2.6
|
||||||
|
deps=
|
||||||
|
django==1.5
|
||||||
|
|
||||||
|
[testenv:py27-django15]
|
||||||
|
basepython=python2.7
|
||||||
|
deps=
|
||||||
|
django==1.5
|
||||||
|
|
||||||
|
[testenv:py26-django14]
|
||||||
|
basepython=python2.6
|
||||||
|
deps=
|
||||||
|
django==1.4.5
|
||||||
|
|
||||||
|
[testenv:py27-django14]
|
||||||
|
basepython=python2.7
|
||||||
|
deps=
|
||||||
|
django==1.4.5
|
||||||
|
|
||||||
Loading…
Reference in New Issue