<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>hacklab.com.br &#187; django</title>
	<atom:link href="http://hacklab.com.br/tag/django/feed/" rel="self" type="application/rss+xml" />
	<link>http://hacklab.com.br</link>
	<description></description>
	<lastBuildDate>Thu, 17 May 2012 19:02:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Django model history with django-reversion</title>
		<link>http://blog.brunogola.com.br/2009/10/django-model-history-with-django-reversion/</link>
		<comments>http://blog.brunogola.com.br/2009/10/django-model-history-with-django-reversion/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 18:06:04 +0000</pubDate>
		<dc:creator>Bruno Gola</dc:creator>
				<category><![CDATA[Software Livre]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[hacking]]></category>

		<guid isPermaLink="false">http://blog.brunogola.com.br/?p=110</guid>
		<description><![CDATA[I&#8217;m currently working on a django project and I needed to track all changes to a model and provide a log showing what has changed (like a wiki).
I&#8217;ve found three extensions/libs that apparently could do the job for me (fullhistory, django-history and django-reversion) so I decided to test them, but because of the lack of [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently working on a <a href="http://www.djangoproject.com/">django</a> project and I needed to track all changes to a model and provide a log showing what has changed (like a wiki).</p>
<p>I&#8217;ve found three extensions/libs that apparently could do the job for me (<a href="http://code.google.com/p/fullhistory/">fullhistory</a>, <a href="http://code.google.com/p/django-history/">django-history</a> and <a href="http://code.google.com/p/django-reversion/">django-reversion</a>) so I decided to test them, but because of the lack of structure/documentation of the other two I tried just the last one. </p>
<h2>django-reversion</h2>
<p> (<a href="http://code.google.com/p/django-reversion/">http://code.google.com/p/django-reversion/</a>)</p>
<p>It has a <a href="http://code.google.com/p/django-reversion/wiki/GettingStarted">good documentation</a>, integration with the admin and the most important for me a <em><a href="http://code.google.com/p/django-reversion/wiki/LowLevelAPI">low level api</a></em>, as I am not using the admin app for this project. </p>
<p>The installation went pretty well (<em>svn co <a href="http://django-reversion.googlecode.com/svn/tags/1.1.2/src/reversion">http://django-reversion.googlecode.com/svn/tags/1.1.2/src/reversion</a></em> to your PYTHONPATH, add the <em>reversion</em> app to your INSTALLED_APPS in <em>settings.py</em> and the usual <em>python manage.py syncdb</em>).</p>
<p>To track the changes of a model you must register it with the <em>reversion</em> framework (importing <em>reversion</em> and calling <em>reversion.register(YourModel)</em>).</p>
<p><em>Reversion</em> provides some ways for creating revisions of your model and the docs recommend that you choose one of them to use in your project. I chose the MiddleWare method because it seemed the better option for our project, but you should look the <a href="http://code.google.com/p/django-reversion/wiki/LowLevelAPI">reversion documentation</a> and decide which one is the best for you.</p>
<p>After registering the model and installing the MiddleWare no more changes are needed, whenever I save a model a new revision is created on the database. Another cool feature is the <em>follow</em> argument when registering a model. That way you can specify a ForeingKey/ManyToMany field to follow. This means that when you save the model a new revision is created with all &#8220;followed&#8221; fields in its current state. It&#8217;s very useful. See the docs for an example.</p>
<p>The only thing that&#8217;s not so clear for me is: what happens if I delete a field from a model that&#8217;s registered within reversion? Can you still restore its versions?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brunogola.com.br/2009/10/django-model-history-with-django-reversion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

