Ticket #9651: patch1.diff
File patch1.diff, 3.6 KB (added by , 16 years ago) |
---|
-
django/forms/models.py
487 487 # Remove the primary key from the form's data, we are only 488 488 # creating new instances 489 489 form.data[form.add_prefix(self._pk_field.name)] = None 490 491 # Remove the foreign key from the form's data 492 form.data[form.add_prefix(self.fk.name)] = None 490 493 return form 491 494 492 495 def save_new(self, form, commit=True): -
tests/regressiontests/admin_views/tests.py
85 85 "article_set-0-content": u"<p>Middle content</p>", 86 86 "article_set-0-date_0": u"2008-03-18", 87 87 "article_set-0-date_1": u"11:54:58", 88 "article_set-0-section": u"1", 88 89 "article_set-1-id": u"2", 89 90 "article_set-1-title": u"Need a title.", 90 91 "article_set-1-content": u"<p>Oldest content</p>", 91 92 "article_set-1-date_0": u"2000-03-18", 92 93 "article_set-1-date_1": u"11:54:58", 94 "article_set-1-section": u"1", 93 95 "article_set-2-id": u"3", 94 96 "article_set-2-title": u"Need a title.", 95 97 "article_set-2-content": u"<p>Newest content</p>", 96 98 "article_set-2-date_0": u"2009-03-18", 97 99 "article_set-2-date_1": u"11:54:58", 100 "article_set-2-section": u"1", 98 101 "article_set-3-id": u"", 99 102 "article_set-3-title": u"", 100 103 "article_set-3-content": u"", 101 104 "article_set-3-date_0": u"", 102 105 "article_set-3-date_1": u"", 106 "article_set-3-section": u"1", 103 107 "article_set-4-id": u"", 104 108 "article_set-4-title": u"", 105 109 "article_set-4-content": u"", 106 110 "article_set-4-date_0": u"", 107 111 "article_set-4-date_1": u"", 112 "article_set-4-section": u"1", 108 113 "article_set-5-id": u"", 109 114 "article_set-5-title": u"", 110 115 "article_set-5-content": u"", 111 116 "article_set-5-date_0": u"", 112 117 "article_set-5-date_1": u"", 118 "article_set-5-section": u"1", 113 119 } 114 120 response = self.client.post('/test_admin/%s/admin_views/section/1/' % self.urlbit, post_data) 115 121 self.failUnlessEqual(response.status_code, 302) # redirect somewhere 116 122 123 # test save_as 124 post_data.update({'_saveasnew': u'Save+as+new',}) 125 response = self.client.post('/test_admin/%s/admin_views/section/1/' % self.urlbit, post_data) 126 self.failUnlessEqual(response.status_code, 302) # redirect somewhere 127 128 117 129 def testChangeListSortingCallable(self): 118 130 """ 119 131 Ensure we can sort on a list_display field that is a callable -
tests/regressiontests/admin_views/models.py
136 136 137 137 admin.site.register(Article, ArticleAdmin) 138 138 admin.site.register(CustomArticle, CustomArticleAdmin) 139 admin.site.register(Section, inlines=[ArticleInline])139 admin.site.register(Section, save_as=True, inlines=[ArticleInline]) 140 140 admin.site.register(ModelWithStringPrimaryKey) 141 141 admin.site.register(Color) 142 142 admin.site.register(Thing, ThingAdmin)