summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-04-29 01:19:42 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-04-29 01:19:42 +0000
commit2061b3f3ca959cc847790ba4b4ee3b23ca31aa52 (patch)
tree65e735028d121db5cbd2c0f7282f688e1f659cee
parent14d6ee2dc956d06fc1014e1b3c1f1410d553157d (diff)
Undo [7474]. I didn't think it through nearly carefully enough.
This means that all model construction now goes through the __init__() method again. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7504 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/db/models/base.py26
-rw-r--r--django/db/models/query.py4
2 files changed, 2 insertions, 28 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py
index bb02d7a00c..181d845932 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -237,32 +237,6 @@ class Model(object):
raise TypeError, "'%s' is an invalid keyword argument for this function" % kwargs.keys()[0]
dispatcher.send(signal=signals.post_init, sender=self.__class__, instance=self)
- def from_sequence(cls, values):
- """
- An alternate class constructor, primarily for internal use.
-
- Creates a model instance from a sequence of values (which corresponds
- to all the non-many-to-many fields in creation order. If there are more
- fields than values, the remaining (final) fields are given their
- default values.
-
- ForeignKey fields can only be initialised using id values, not
- instances, in this method.
- """
- dispatcher.send(signal=signals.pre_init, sender=cls, args=values,
- kwargs={})
- obj = Empty()
- obj.__class__ = cls
- field_iter = iter(obj._meta.fields)
- for val, field in izip(values, field_iter):
- setattr(obj, field.attname, val)
- for field in field_iter:
- setattr(obj, field.attname, field.get_default())
- dispatcher.send(signal=signals.post_init, sender=cls, instance=obj)
- return obj
-
- from_sequence = classmethod(from_sequence)
-
def __repr__(self):
return smart_str(u'<%s: %s>' % (self.__class__.__name__, unicode(self)))
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 65048c7ba8..6b341ba9ab 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -164,7 +164,7 @@ class QuerySet(object):
obj, _ = get_cached_row(self.model, row, index_start,
max_depth, requested=requested)
else:
- obj = self.model.from_sequence(row[index_start:])
+ obj = self.model(*row[index_start:])
for i, k in enumerate(extra_select):
setattr(obj, k, row[i])
yield obj
@@ -655,7 +655,7 @@ def get_cached_row(klass, row, index_start, max_depth=0, cur_depth=0,
restricted = requested is not None
index_end = index_start + len(klass._meta.fields)
- obj = klass.from_sequence(row[index_start:index_end])
+ obj = klass(*row[index_start:index_end])
for f in klass._meta.fields:
if (not f.rel or (not restricted and f.null) or
(restricted and f.name not in requested) or f.rel.parent_link):