1👍
✅
Firstly, Because You’ll want to access your user’s history directly from a User instance, use django’s ForeignKey field.
When doing so, accessing a users history will look something like this:
my_user.information_set.all()
You can change the name the user’s history from ‘information_set’ to, for example, ‘history’, by specifying related_name argument in the ForeignKey constructor, like so:
Class Information(models.Model):
...
user=models.ForeignKey(related_name='history')
And now to access a user’s history, you can write:
my_user.history.all()
Also, Please notice that in your current design, the info won’t be stored in the database.
I assume that most of the history data you want to store will have the same structure. Consider using a field for each piece of info you want to keep in your history. For example, for keeping the date and time of the action, use DateTimeField
Source:stackexchange.com