mirror of
https://github.com/django/django.git
synced 2025-07-05 18:29:11 +00:00
queryset-refactor: Fixed a few inadvertent sharing problems for related fields
in abstract base classes. This means, for example, that many-to-many fields can be used in abstract base classes. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7431 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
a14135e14f
commit
b114fecfe4
@ -1,3 +1,4 @@
|
|||||||
|
import copy
|
||||||
import types
|
import types
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
@ -111,7 +112,7 @@ class ModelBase(type):
|
|||||||
if field.name in names:
|
if field.name in names:
|
||||||
raise FieldError('Local field %r in class %r clashes with field of similar name from abstract base class %r'
|
raise FieldError('Local field %r in class %r clashes with field of similar name from abstract base class %r'
|
||||||
% (field.name, name, base.__name__))
|
% (field.name, name, base.__name__))
|
||||||
new_class.add_to_class(field.name, field)
|
new_class.add_to_class(field.name, copy.deepcopy(field))
|
||||||
|
|
||||||
if abstract:
|
if abstract:
|
||||||
# Abstract base models can't be instantiated and don't appear in
|
# Abstract base models can't be instantiated and don't appear in
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
@ -126,11 +127,13 @@ class Field(object):
|
|||||||
return cmp(self.creation_counter, other.creation_counter)
|
return cmp(self.creation_counter, other.creation_counter)
|
||||||
|
|
||||||
def __deepcopy__(self, memodict):
|
def __deepcopy__(self, memodict):
|
||||||
# Slight hack; deepcopy() is difficult to do on classes with
|
# We don't have to deepcopy very much here, since most things are not
|
||||||
# dynamically created methods. Fortunately, we can get away with doing
|
# intended to be altered after initial creation.
|
||||||
# a shallow copy in this particular case.
|
obj = copy.copy(self)
|
||||||
import copy
|
if self.rel:
|
||||||
return copy.copy(self)
|
obj.rel = copy.copy(self.rel)
|
||||||
|
memodict[id(self)] = obj
|
||||||
|
return obj
|
||||||
|
|
||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user