Django

Code

Ticket #2259: pk_change.diff

File pk_change.diff, 0.7 kB (added by pigletto, 2 years ago)
  • tests/modeltests/basic/models.py

    old new  
    384384>>> a.save() 
    385385>>> Article.objects.get(pk=a.id).headline 
    386386u'\u6797\u539f \u3081\u3050\u307f' 
     387 
     388# It is possible to change primary key value 
     389>>> bc = Article(headline="primary changed article", pub_date=datetime(2008, 1, 1)) 
     390>>> bc.save() 
     391>>> total = Article.objects.all().count() 
     392 
     393# After changing primary key value we still have same number of objects 
     394>>> bc.id = 999 
     395>>> bc.save() 
     396>>> print total == Article.objects.all().count() 
     397True 
    387398"""