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 6183699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:24:40+00:00 2026-05-24T01:24:40+00:00

I know Django has a feature of last_modified field (models.DateTimeField(auto_now_add=True) ).. but let’s say

  • 0

I know Django has a feature of last_modified field (models.DateTimeField(auto_now_add=True)
)..

but let’s say I have a certain App, and I want to know when was the last change for any of its Model (I don’t really care which model was changed, I just want to know when was the latest change for this app..)

do I really have to write a last_modified field for each model (I have 9 of them for the moment…), and then check for each of them which is the latest?

any help will be appreciated 🙂
Thanks

  • 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-24T01:24:40+00:00Added an answer on May 24, 2026 at 1:24 am

    In The End I made a table for constants for my app (actually I had it before for use of other things).
    so the Table looks like this:

    from django.db import models
    from django.db.models.signals import post_save
    
    class Constant(models.Model):
        name = models.CharField(max_length=50)
        value = models.CharField(max_length=50)
    

    and added a consant named “version_date”.

    Than, I added this code to the bottom of my models.py, to track all changes in all the models in the app.

    myapp = models.get_app('myapp')
    models2track = models.get_models(myapp)
    def update_version(sender, **kwargs):
        for model in models2track:
            post_save.disconnect(update_version, sender=model, dispatch_uid="some_uid"+model._meta.db_table)
    
        version_date = Constant.objects.get_or_create(id=1,name="version date")[0]
        version_date.value = str(int(time.time()))
        version_date.save()
    
        for model in models2track:
            post_save.connect(update_version, sender=model, dispatch_uid="some_uid"+model._meta.db_table)
    
    for model in models2track:
        post_save.connect(update_version, sender=model, dispatch_uid="some_uid"+model._meta.db_table)
    

    This way, I don’t need to change my DB Schema.. only need to add the code mentioned.
    thanks all

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

Sidebar

Related Questions

I know you can override delete and save methods in DJango models, but can
I have this models in Django: News Comments Reactions Relations are: a News has
I know this isn't exactly Django templating philosophy, but i'd like to be able
Django has an excellent support for internationalization, any English expression within Models, Forms, View
I know this exists django-admin.py inspectdb > models.py However, is there an easy way
I know this has probably been asked before, but I can't find it with
In django, I have a table of people, each of which has a namefirst
I have a Django project that has multiple django apps. One of them has
i know the django has some cache method such as the The per-site cache,The
I know django 1.4 has functionality to remove Sensible information in error report.I am

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.