1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #81 -- Admin now supports primary_key=True for non-integer fields. Note that you'll have to make a change to your database if you're using a previous Django installation and want to use non-integer primary key fields. See the BackwardsIncompatibleChanges wiki page for info.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@469 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty
2005-08-10 19:32:38 +00:00
parent b3ae12fa4a
commit 199938649e
5 changed files with 9 additions and 7 deletions

View File

@@ -1338,7 +1338,7 @@ def manipulator_init(opts, add, change, self, obj_key=None):
assert obj_key is not None, "ChangeManipulator.__init__() must be passed obj_key parameter."
self.obj_key = obj_key
try:
self.original_object = opts.get_model_module().get_object(**{'%s__exact' % opts.pk.name: obj_key})
self.original_object = opts.get_model_module().get_object(pk=obj_key)
except ObjectDoesNotExist:
# If the object doesn't exist, this might be a manipulator for a
# one-to-one related object that hasn't created its subobject yet.
@@ -1358,7 +1358,7 @@ def manipulator_init(opts, add, change, self, obj_key=None):
raise
self.fields = []
for f in opts.fields + opts.many_to_many:
if f.editable and (not f.rel or not f.rel.edit_inline):
if f.editable and not (f.primary_key and change) and (not f.rel or not f.rel.edit_inline):
self.fields.extend(f.get_manipulator_fields(opts, self, change))
# Add fields for related objects.

View File

@@ -179,7 +179,7 @@ class Field(object):
params['validator_list'].append(getattr(manipulator, 'isUnique%sFor%s' % (self.name, self.unique_for_month)))
if self.unique_for_year:
params['validator_list'].append(getattr(manipulator, 'isUnique%sFor%s' % (self.name, self.unique_for_year)))
if self.unique:
if self.unique or (self.primary_key and not rel):
params['validator_list'].append(curry(manipulator_validator_unique, self, opts, manipulator))
# Only add is_required=True if the field cannot be blank. Primary keys