1
0
mirror of https://github.com/django/django.git synced 2025-10-28 08:06:09 +00:00

Fixed #21674 -- Deprecated the import_by_path() function in favor of import_string().

Thanks Aymeric Augustin for the suggestion and review.
This commit is contained in:
Berker Peksag
2014-01-20 22:15:14 +02:00
committed by Tim Graham
parent fcc21837dc
commit 5d263dee30
31 changed files with 155 additions and 95 deletions

View File

@@ -3,7 +3,7 @@ from django.apps.registry import Apps
from django.db import models
from django.db.models.options import DEFAULT_NAMES, normalize_unique_together
from django.utils import six
from django.utils.module_loading import import_by_path
from django.utils.module_loading import import_string
class InvalidBasesError(ValueError):
@@ -115,7 +115,7 @@ class ModelState(object):
fields = []
for field in model._meta.local_fields:
name, path, args, kwargs = field.deconstruct()
field_class = import_by_path(path)
field_class = import_string(path)
try:
fields.append((name, field_class(*args, **kwargs)))
except TypeError as e:
@@ -127,7 +127,7 @@ class ModelState(object):
))
for field in model._meta.local_many_to_many:
name, path, args, kwargs = field.deconstruct()
field_class = import_by_path(path)
field_class = import_string(path)
try:
fields.append((name, field_class(*args, **kwargs)))
except TypeError as e:
@@ -175,7 +175,7 @@ class ModelState(object):
fields = []
for name, field in self.fields:
_, path, args, kwargs = field.deconstruct()
field_class = import_by_path(path)
field_class = import_string(path)
fields.append((name, field_class(*args, **kwargs)))
# Now make a copy
return self.__class__(