Best strategy for integrating with django-reversion
See original GitHub issueLet’s say I have a model:
from parler.models import TranslatableModel, TranslatedFields
...
class House(TranslatableModel, models.Model):
global_name = models.SlugField(max_length=255, db_index=True)
translations = TranslatedFields(
name=models.CharField(max_length=255),
description=models.CharField(max_length=255, blank=True),
)
Registering this model with Reversion is generally as easy as:
from reversion import VersionAdmin
class HouseAdmin(VersionAdmin):
...
This won’t follow fk or m2m relations by default, so I have added this to a common app:
reversion.register(HouseTranslation)
and this to the models.py
described above:
reversion.register(House, follow=["translations"])
which doesn’t seem to restore properly. It is always displaying the most recent revision/versions no matter which historical revision you view. Via the command line, I can see that the correct data appears to be written to the revision, including a version for the parent model, and a version for the translated attributes model. Is this at all the correct way to do this, or is there some alternative method? I am looking into VersionAdapters to do this in a custom way, but want to see if there are simpler methods.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Low-level API — django-reversion 1.8.0 documentation
The simplest way to create revisions is to use reversion.middleware.RevisionMiddleware . This will automatically wrap every request in a revision, ensuring that ...
Read more >How to integrate django-reversion in django-rest-framework ...
How to integrate django-reversion in django-rest-framework ModelViewSet. ... Pretty great for time-traveling inside your records, ...
Read more >How to provide view for django-reversion History objects?
Include this Mixin in all the views containing models that have been registered with django-reversion. Hope this helps a bit. Best!!
Read more >django-reversion - LowLevelAPI.wiki - Google Code
Perhaps the simplest way to create revisions is to use reversion.middleware.RevisionMiddleware . This will automatically wrap every request in a revision, ...
Read more >My essential django package list - /var/
django -reversion is a really important package for my projects. ... but if you need full auditing then is is probably the best...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It seems that Aldryn is actively using django-parler for multilingual support, and they have written a version adapter for it. It’s worth looking at, and if anyone would be able to port that into a module for parler, I’d be very happy!
See:
Thank you.