mirror of https://github.com/django/django.git
Fixed #6755: model inheritance now works in the admin. Thanks, sloonz and Michael Placentra.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8033 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
c236874c48
commit
863f4eb1d7
2
AUTHORS
2
AUTHORS
|
@ -303,6 +303,7 @@ answer newbie questions, and generally made Django that much better:
|
||||||
phil@produxion.net
|
phil@produxion.net
|
||||||
phil.h.smith@gmail.com
|
phil.h.smith@gmail.com
|
||||||
Gustavo Picon
|
Gustavo Picon
|
||||||
|
Michael Placentra II <someone@michaelplacentra2.net>
|
||||||
Luke Plant <http://lukeplant.me.uk/>
|
Luke Plant <http://lukeplant.me.uk/>
|
||||||
plisk
|
plisk
|
||||||
Mihai Preda <mihai_preda@yahoo.com>
|
Mihai Preda <mihai_preda@yahoo.com>
|
||||||
|
@ -342,6 +343,7 @@ answer newbie questions, and generally made Django that much better:
|
||||||
jason.sidabras@gmail.com
|
jason.sidabras@gmail.com
|
||||||
Jozko Skrablin <jozko.skrablin@gmail.com>
|
Jozko Skrablin <jozko.skrablin@gmail.com>
|
||||||
Ben Slavin <benjamin.slavin@gmail.com>
|
Ben Slavin <benjamin.slavin@gmail.com>
|
||||||
|
sloonz <simon.lipp@insa-lyon.fr>
|
||||||
SmileyChris <smileychris@gmail.com>
|
SmileyChris <smileychris@gmail.com>
|
||||||
smurf@smurf.noris.de
|
smurf@smurf.noris.de
|
||||||
Vsevolod Solovyov
|
Vsevolod Solovyov
|
||||||
|
|
|
@ -299,6 +299,12 @@ class Model(object):
|
||||||
# attributes we have been given to the class we have been given.
|
# attributes we have been given to the class we have been given.
|
||||||
if not raw:
|
if not raw:
|
||||||
for parent, field in meta.parents.items():
|
for parent, field in meta.parents.items():
|
||||||
|
# At this point, parent's primary key field may be unknown
|
||||||
|
# (for example, from administration form which doesn't fill
|
||||||
|
# this field). If so, fill it.
|
||||||
|
if getattr(self, parent._meta.pk.attname) is None and getattr(self, field.attname) is not None:
|
||||||
|
setattr(self, parent._meta.pk.attname, getattr(self, field.attname))
|
||||||
|
|
||||||
self.save_base(raw, parent)
|
self.save_base(raw, parent)
|
||||||
setattr(self, field.attname, self._get_pk_val(parent._meta))
|
setattr(self, field.attname, self._get_pk_val(parent._meta))
|
||||||
|
|
||||||
|
|
|
@ -706,6 +706,7 @@ class OneToOneField(ForeignKey):
|
||||||
"""
|
"""
|
||||||
def __init__(self, to, to_field=None, **kwargs):
|
def __init__(self, to, to_field=None, **kwargs):
|
||||||
kwargs['unique'] = True
|
kwargs['unique'] = True
|
||||||
|
kwargs['editable'] = False
|
||||||
if 'num_in_admin' not in kwargs:
|
if 'num_in_admin' not in kwargs:
|
||||||
kwargs['num_in_admin'] = 0
|
kwargs['num_in_admin'] = 0
|
||||||
super(OneToOneField, self).__init__(to, to_field, OneToOneRel, **kwargs)
|
super(OneToOneField, self).__init__(to, to_field, OneToOneRel, **kwargs)
|
||||||
|
|
|
@ -159,4 +159,19 @@ Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
DoesNotExist: ItalianRestaurant matching query does not exist.
|
DoesNotExist: ItalianRestaurant matching query does not exist.
|
||||||
|
|
||||||
|
# Regression test for #6755
|
||||||
|
>>> r = Restaurant(serves_pizza=False)
|
||||||
|
>>> r.save()
|
||||||
|
>>> r.id
|
||||||
|
3
|
||||||
|
>>> r.place_ptr_id
|
||||||
|
3
|
||||||
|
>>> r = Restaurant(place_ptr_id=3, serves_pizza=True)
|
||||||
|
>>> r.save()
|
||||||
|
>>> r.id
|
||||||
|
3
|
||||||
|
>>> r.place_ptr_id
|
||||||
|
3
|
||||||
|
|
||||||
|
|
||||||
"""}
|
"""}
|
||||||
|
|
Loading…
Reference in New Issue