Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
49f95cc0
Kaydet (Commit)
49f95cc0
authored
Mar 27, 2016
tarafından
Akshesh
Kaydeden (comit)
Tim Graham
Mar 30, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #11560 -- Allowed proxy model multiple-inheritance from the same concrete base model.
üst
2e0cd26f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
8 deletions
+29
-8
base.py
django/db/models/base.py
+3
-3
1.10.txt
docs/releases/1.10.txt
+3
-0
models.txt
docs/topics/db/models.txt
+7
-1
models.py
tests/proxy_models/models.py
+10
-0
tests.py
tests/proxy_models/tests.py
+6
-4
No files found.
django/db/models/base.py
Dosyayı görüntüle @
49f95cc0
...
...
@@ -177,10 +177,10 @@ class ModelBase(type):
)
else
:
continue
if
base
is
not
None
:
raise
TypeError
(
"Proxy model '
%
s' has more than one non-abstract model base class."
%
name
)
else
:
if
base
is
None
:
base
=
parent
elif
parent
.
_meta
.
concrete_model
is
not
base
.
_meta
.
concrete_model
:
raise
TypeError
(
"Proxy model '
%
s' has more than one non-abstract model base class."
%
name
)
if
base
is
None
:
raise
TypeError
(
"Proxy model '
%
s' has no non-abstract model base class."
%
name
)
new_class
.
_meta
.
setup_proxy
(
base
)
...
...
docs/releases/1.10.txt
Dosyayı görüntüle @
49f95cc0
...
...
@@ -359,6 +359,9 @@ Models
* Added the :class:`~django.db.models.functions.Cast` database function.
* A proxy model may now inherit multiple proxy models that share a common
non-abstract parent class.
Requests and Responses
~~~~~~~~~~~~~~~~~~~~~~
...
...
docs/topics/db/models.txt
Dosyayı görüntüle @
49f95cc0
...
...
@@ -1230,7 +1230,13 @@ A proxy model must inherit from exactly one non-abstract model class. You
can't inherit from multiple non-abstract models as the proxy model doesn't
provide any connection between the rows in the different database tables. A
proxy model can inherit from any number of abstract model classes, providing
they do *not* define any model fields.
they do *not* define any model fields. A proxy model may also inherit from any
number of proxy models that share a common non-abstract parent class.
.. versionchanged:: 1.10
In earlier versions, a proxy model couldn't inherit more than one proxy
model that shared the same parent class.
Proxy model managers
~~~~~~~~~~~~~~~~~~~~
...
...
tests/proxy_models/models.py
Dosyayı görüntüle @
49f95cc0
...
...
@@ -110,10 +110,20 @@ class UserProxy(User):
proxy
=
True
class
AnotherUserProxy
(
User
):
class
Meta
:
proxy
=
True
class
UserProxyProxy
(
UserProxy
):
class
Meta
:
proxy
=
True
class
MultiUserProxy
(
UserProxy
,
AnotherUserProxy
):
class
Meta
:
proxy
=
True
# We can still use `select_related()` to include related models in our querysets.
...
...
tests/proxy_models/tests.py
Dosyayı görüntüle @
49f95cc0
...
...
@@ -13,9 +13,9 @@ from django.urls import reverse
from
.admin
import
admin
as
force_admin_model_registration
# NOQA
from
.models
import
(
Abstract
,
BaseUser
,
Bug
,
Country
,
Improvement
,
Issue
,
LowerStatusPerson
,
M
yPerson
,
MyPersonProxy
,
OtherPerson
,
Person
,
ProxyBug
,
ProxyImprovement
,
Proxy
ProxyBug
,
ProxyTrackerUser
,
State
,
StateProxy
,
StatusPerson
,
TrackerUser
,
User
,
UserProxy
,
UserProxyProxy
,
M
ultiUserProxy
,
MyPerson
,
MyPersonProxy
,
OtherPerson
,
Person
,
ProxyBug
,
Proxy
Improvement
,
ProxyProxyBug
,
ProxyTrackerUser
,
State
,
StateProxy
,
StatusPerson
,
TrackerUser
,
User
,
UserProxy
,
UserProxyProxy
,
)
...
...
@@ -246,7 +246,7 @@ class ProxyModelTests(TestCase):
ctype
=
ContentType
.
objects
.
get_for_model
self
.
assertIs
(
ctype
(
Person
),
ctype
(
OtherPerson
))
def
test_user_
userproxy_userproxyproxy
(
self
):
def
test_user_
proxy_models
(
self
):
User
.
objects
.
create
(
name
=
'Bruce'
)
resp
=
[
u
.
name
for
u
in
User
.
objects
.
all
()]
...
...
@@ -258,6 +258,8 @@ class ProxyModelTests(TestCase):
resp
=
[
u
.
name
for
u
in
UserProxyProxy
.
objects
.
all
()]
self
.
assertEqual
(
resp
,
[
'Bruce'
])
self
.
assertEqual
([
u
.
name
for
u
in
MultiUserProxy
.
objects
.
all
()],
[
'Bruce'
])
def
test_proxy_for_model
(
self
):
self
.
assertEqual
(
UserProxy
,
UserProxyProxy
.
_meta
.
proxy_for_model
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment