Django database and information history

I am using Django framework to build a website with the ability to record user information and its history of modification. As what i can image, i can use a Django self-defined app to record the information history. This self-defined app would contain classes with information stored in dictionary.

    Class Information(models.Model):
        user = models.OneToOneField(User)

        info = {'date': value}

    def create_information(sender, instance, created, **kwargs):
    if created:
    post_save.connect(create_control_information, sender=User)

Can any one tell me if there is some other better way to record information in Django web developing?


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:


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):

And now to access a user's history, you can write:


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

Need Your Help

In Rails, what's the relation between find_each and where?

ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4 activerecord

In Rails, both find_each and where are used for retrieving data from Database supported by ActiveRecord.

How to create a bot that simulate an SSH shell user interaction?

java linux shell ssh jsch

I'm trying to realize a bot that simulates an user that write/read on a ssh console in Java.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.