Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 25th, 2013  |  syntax: Python  |  size: 1.01 KB  |  views: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. In [166]: with reversion.create_revision():
  2.   for o in Res.objects.all():
  3.     o.save()
  4.    .....:
  5.  
  6. In [169]: Res.objects.all().delete()
  7. In [170]: reversion.models.Revision.objects.all()
  8. Out[170]: [<Revision: a>, <Revision: b>, <Revision: a>, <Revision: b>, <Revision: a>, <Revision: b>, <Revision: #00001>, <Revision: name: <bb>, desc: <bb>, doc: <bb>, group: <bb>-<bb>, #00002>]
  9. In [174]: from django.contrib.contenttypes.models import ContentType
  10.  
  11. In [175]: r = reversion.models.Revision.objects.filter(content_type=ContentType.objects.get_for_model(Res)).order_by("-date_created")[0]
  12. FieldError: Cannot resolve keyword 'content_type' into field. Choices are: comment, date_created, id, manager_slug, user, version
  13.  
  14.  
  15. In [176]: r = reversion.models.Revision.objects.all().order_by("-date_created")[0]
  16. In [177]: r
  17. Out[177]: <Revision: name: <bb>, desc: <bb>, doc: <bb>, group: <bb>-<bb>, #00002>
  18. In [179]: r.version_set.all()
  19. Out[179]: [<Version: name: <bb>, desc: <bb>, doc: <bb>, group: <bb>-<bb>>, <Version: #00002>]
clone this paste RAW Paste Data