diff --git a/django/conf/urls/admin.py b/django/conf/urls/admin.py index dbe30940d6..841d50523e 100644 --- a/django/conf/urls/admin.py +++ b/django/conf/urls/admin.py @@ -50,9 +50,9 @@ urlpatterns += ( # Metasystem admin pages ('^(?P[^/]+)/(?P[^/]+)/$', 'django.views.admin.main.change_list'), ('^(?P[^/]+)/(?P[^/]+)/add/$', 'django.views.admin.main.add_stage'), - ('^(?P[^/]+)/(?P[^/]+)/(?P\d+)/$', 'django.views.admin.main.change_stage'), - ('^(?P[^/]+)/(?P[^/]+)/(?P\d+)/delete/$', 'django.views.admin.main.delete_stage'), - ('^(?P[^/]+)/(?P[^/]+)/(?P\d+)/history/$', 'django.views.admin.main.history'), ('^(?P[^/]+)/(?P[^/]+)/jsvalidation/$', 'django.views.admin.jsvalidation.jsvalidation'), + ('^(?P[^/]+)/(?P[^/]+)/(?P.+)/history/$', 'django.views.admin.main.history'), + ('^(?P[^/]+)/(?P[^/]+)/(?P.+)/delete/$', 'django.views.admin.main.delete_stage'), + ('^(?P[^/]+)/(?P[^/]+)/(?P.+)/$', 'django.views.admin.main.change_stage'), ) urlpatterns = patterns('', *urlpatterns) diff --git a/django/core/meta/__init__.py b/django/core/meta/__init__.py index 99abbd728c..554ba4eda0 100644 --- a/django/core/meta/__init__.py +++ b/django/core/meta/__init__.py @@ -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. diff --git a/django/core/meta/fields.py b/django/core/meta/fields.py index 46e317dca4..adbfe4ca92 100644 --- a/django/core/meta/fields.py +++ b/django/core/meta/fields.py @@ -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 diff --git a/django/models/auth.py b/django/models/auth.py index 0b6d01069e..91ed0650ec 100644 --- a/django/models/auth.py +++ b/django/models/auth.py @@ -247,7 +247,7 @@ class LogEntry(meta.Model): meta.DateTimeField('action_time', auto_now=True), meta.ForeignKey(User), meta.ForeignKey(core.ContentType, name='content_type_id', rel_name='content_type', blank=True, null=True), - meta.IntegerField('object_id', blank=True, null=True), + meta.TextField('object_id', blank=True, null=True), meta.CharField('object_repr', maxlength=200), meta.PositiveSmallIntegerField('action_flag'), meta.TextField('change_message', blank=True), diff --git a/django/views/admin/main.py b/django/views/admin/main.py index 210523a8bb..430ae15744 100644 --- a/django/views/admin/main.py +++ b/django/views/admin/main.py @@ -719,6 +719,8 @@ def _get_admin_field(field_list, name_prefix, rel, add, change): class_names.append('inline') t.append(' ' % (label_name, class_names and ' class="%s"' % ' '.join(class_names) or '', capfirst(field.verbose_name))) t.append(_get_admin_field_form_widget(field, name_prefix, rel, add, change)) + if change and field.primary_key: + t.append('{{ %soriginal.%s }}' % ((rel and name_prefix or ''), field.name)) if change and use_raw_id_admin(field): obj_repr = '%soriginal.get_%s|truncatewords:"14"' % (rel and name_prefix or '', field.rel.name) t.append('{%% if %s %%} {{ %s }}{%% endif %%}' % (obj_repr, obj_repr))