Tracking changes to ForeignKey and ManyToManyFields

125 views
Skip to first unread message

Anupam Jain

unread,
Jun 1, 2017, 7:37:26 AM6/1/17
to django-reversion discussion group
I'm new to django-reversion. Do I have to do anything special to track changes to ForeignKey or ManyToManyFields?

I'm using django-reversion-compare to see the comparisons for every revision visually but it says the following at the end:

Fields/entries marked with * are not under reversion control. It may be that not all marked information are correct.

which makes me believe that I may have missed out something while setting up django-reversion. 
(I am using the decorator @reversion.create_revision() to track changes and setting reversion.set_comment(), reversion.set_user() as needed). 

When I see the comparisons in django-reversion-compare, all revisions are captured nicely except for ManyToManyFields and ForeignKey fields. I opened an issue on django-reversion-compare but now realising that it might be something to do with the way I am using reversion in my app. 

Thanks.



--
"What is meditation?" (http://www.heartfulness.org/)

Anupam Jain

unread,
Jun 1, 2017, 7:40:24 AM6/1/17
to django-reversion discussion group
I also searched for ManyToManyField in django-reversion docs and read about follow() but couldn't quite follow it :)  I never used reversion.register() anywhere in my code. Do I have to manually mention all model relationships when using FK or M2M?

Dave Hall

unread,
Jun 2, 2017, 4:19:25 AM6/2/17
to django-reversion discussion group
If you are using the django admin integration, you just need to add another method to your admin class:

def reversion_register(self, model, **options):
    options["follow"] = ("some_fk", "some_m2m",)
    super(YourModelAdmin, self).reversion_register(model, **options)

--
You received this message because you are subscribed to the Google Groups "django-reversion discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-reversi...@googlegroups.com.
To post to this group, send email to django-r...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-reversion.
For more options, visit https://groups.google.com/d/optout.

Anupam Jain

unread,
Jun 7, 2017, 3:46:21 AM6/7/17
to django-reversion discussion group
Anyone? 

Thanks!

Dave Hall

unread,
Jun 7, 2017, 4:09:37 AM6/7/17
to django-r...@googlegroups.com
I already replied. Here is is again!

VVVVVVVVVVVVVVVVVVVV


If you are using the django admin integration, you just need to add another method to your admin class:

def reversion_register(self, model, **options):
    options["follow"] = ("some_fk", "some_m2m",)
    super(YourModelAdmin, self).reversion_register(model, **options)

--
You received this message because you are subscribed to the Google Groups "django-reversion discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-reversion+unsubscribe@googlegroups.com.
To post to this group, send email to django-reversion@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages