Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6082343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:16:43+00:00 2026-05-23T11:16:43+00:00

I am using django-reversion in my project. And it works good except one thing:

  • 0

I am using django-reversion in my project.
And it works good except one thing:
I can’t get previous versions of ManyToMany fields. But in django admin it is works, not in my code.
To get previous version I use following code:

vprod = Version.objects.get_for_date(product, ondate).get_object_version().object

and it works except m2m field
where ‘product’ is object of Product class,

class Product(models.Model):
    name = models.CharField(max_length=255)
    elements = models.ManyToManyField(Sku)

class Sku(models.Model):
    name = models.CharField(max_length=255, verbose_name="SKU Name")

I can get vprod.name and it returns what I need, but when I try vprod.elements.all() it returns list only the current (last) version, even if the number of elements changed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:16:44+00:00Added an answer on May 23, 2026 at 11:16 am

    If I understand it correctly, I think you should get the revision for the version; the version contains the data of the object, the revision contains versions for multiple objects. Have a look at:

    some_version.revision.version_set.all()

    Concretely, I think you should use (untested):

    [
    v for v in Version.objects.get_for_date(product, ondate).revision.version_set.all()
    if version.content_type == ContentType.objects.get_for_model(Sku)
    ]

    Note, btw, that reversions should know that it should follow relationships. Using the low level API:

    reversion.register(YourModel, follow=[“your_foreign_key_field”])

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a small web project using Django that has one model ( Image
Using Django's built in models, how would one create a triple-join between three models.
I'm considering using Django for a project I'm starting (fyi, a browser-based game) and
I'm using what the django-reversion documents call the low-level API in order to access
I'm using django-reversion for providing history for models I discovered that reversion creates two
I’ve got a brand new Django project. I’ve added one minimal view function to
I'm using Django for a project, and I want to use a couple of
When using Django sessions , is it good practice to see if session data
Using django, I am authenticating the user through Google. I get the initial request
Been using Django for < 1yr now, but this one is new-to-me. Hopefully someone?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.