2014-01-30 34 views
0

當我做我的Django模型的變化,我怎麼能在admin添加一個歷史?當我保存在其他模板或Shell歷史觀添加到我的模型在Django

我使用Django 1.6在管理員。更改已存儲,但在另一個模板中我看不到這些更改。我該如何解決這個問題?

class Modelo(models.Model): 
    nombre = models.CharField(max_length=100) 
    marca = models.ForeignKey(Marca) 
    def __unicode__(self): 
     return self.nombre 
    class Meta: 
     unique_together = ("nombre", "marca") 
     verbose_name_plural = u'Modelos' 
     verbose_name=u'Modelos' 

回答

0

可以使用django-simple-history應用

一些簡單的使用(從文檔,您配置的應用程序後):

>>> from polls.models import Poll, Choice 
>>> from datetime import datetime 
>>> poll = Poll.objects.create(question="what's up?", pub_date=datetime.now()) 
>>> 
>>> poll.history.all() 
[<HistoricalPoll: Poll object as of 2010-10-25 18:03:29.855689>]