Answer the question
In order to leave comments, you need to log in
Django abstract model?
For all system models, I created an abstract model that stores the date of the last change of the record
class CommonInfo(models.Model):
last_modified_date = models.DateTimeField(auto_now=True)
class Meta:
abstract = True
Answer the question
In order to leave comments, you need to log in
I have not tried to do this, but the general idea is this:
You can use middleware to write the current request to the thread variable (thread local). (For example https://github.com/nebstrebor/django-threadlocals)
Then it will be possible to get to the current user from the model.
In the abstract model, define a save method that will write the user attribute.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question