question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Best strategy for integrating with django-reversion

See original GitHub issue

Let’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:open
  • Created 9 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vdboorcommented, Jun 25, 2015

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:

0reactions
esistgutcommented, Dec 1, 2014

Thank you.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found