Skip to content

Instantly share code, notes, and snippets.

@flaviodesousa
Created July 13, 2012 00:54
Show Gist options
  • Save flaviodesousa/3102088 to your computer and use it in GitHub Desktop.
Save flaviodesousa/3102088 to your computer and use it in GitHub Desktop.
Exemplo de modelo de documento versionado
class Documento(models.Model):
nome = models.CharField(max_length=128)
autor = models.CharField(max_length=128)
versao_atual = models.ForeignKey('Versao', related_name='+')
class Versao(models.Model):
texto = models.TextField()
criacao = models.DateTimeField(auto_now_add=True)
documento = models.ForeignKey(Documento, related_name='versoes')
class Meta:
verbose_name = u'Versão'
verbose_name_plural = u'Versões'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment