Ticket #9651: 9651-r10336.diff

File 9651-r10336.diff, 3.5 KB (added by Michael Newman, 16 years ago)

Updated patch to r10336

  • django/forms/models.py

     
    530530            # Remove the primary key from the form's data, we are only
    531531            # creating new instances
    532532            form.data[form.add_prefix(self._pk_field.name)] = None
     533
     534            # Remove the foreign key from the form's data
     535            form.data[form.add_prefix(self.fk.name)] = None
    533536        return form
    534537
    535538    #@classmethod
  • tests/regressiontests/admin_views/tests.py

     
    9494            "article_set-0-content": u"<p>Middle content</p>",
    9595            "article_set-0-date_0": u"2008-03-18",
    9696            "article_set-0-date_1": u"11:54:58",
     97            "article_set-0-section": u"1",
    9798            "article_set-1-id": u"2",
    9899            "article_set-1-title": u"Need a title.",
    99100            "article_set-1-content": u"<p>Oldest content</p>",
    100101            "article_set-1-date_0": u"2000-03-18",
    101102            "article_set-1-date_1": u"11:54:58",
     103            "article_set-1-section": u"1",
    102104            "article_set-2-id": u"3",
    103105            "article_set-2-title": u"Need a title.",
    104106            "article_set-2-content": u"<p>Newest content</p>",
    105107            "article_set-2-date_0": u"2009-03-18",
    106108            "article_set-2-date_1": u"11:54:58",
     109            "article_set-2-section": u"1",
    107110            "article_set-3-id": u"",
    108111            "article_set-3-title": u"",
    109112            "article_set-3-content": u"",
    110113            "article_set-3-date_0": u"",
    111114            "article_set-3-date_1": u"",
     115            "article_set-3-section": u"1",
    112116            "article_set-4-id": u"",
    113117            "article_set-4-title": u"",
    114118            "article_set-4-content": u"",
    115119            "article_set-4-date_0": u"",
    116120            "article_set-4-date_1": u"",
     121            "article_set-4-section": u"1",
    117122            "article_set-5-id": u"",
    118123            "article_set-5-title": u"",
    119124            "article_set-5-content": u"",
    120125            "article_set-5-date_0": u"",
    121126            "article_set-5-date_1": u"",
     127            "article_set-5-section": u"1",
    122128        }
    123129        response = self.client.post('/test_admin/%s/admin_views/section/1/' % self.urlbit, post_data)
    124130        self.failUnlessEqual(response.status_code, 302) # redirect somewhere
    125131
     132        # test save_as
     133        post_data.update({'_saveasnew': u'Save+as+new',})
     134        response = self.client.post('/test_admin/%s/admin_views/section/1/' % self.urlbit, post_data)
     135        self.failUnlessEqual(response.status_code, 302) # redirect somewhere
     136
     137
    126138    def testChangeListSortingCallable(self):
    127139        """
    128140        Ensure we can sort on a list_display field that is a callable
  • tests/regressiontests/admin_views/models.py

     
    287287
    288288admin.site.register(Article, ArticleAdmin)
    289289admin.site.register(CustomArticle, CustomArticleAdmin)
    290 admin.site.register(Section, inlines=[ArticleInline])
     290admin.site.register(Section, save_as=True, inlines=[ArticleInline])
    291291admin.site.register(ModelWithStringPrimaryKey)
    292292admin.site.register(Color)
    293293admin.site.register(Thing, ThingAdmin)
Back to Top