How to freeze models without denormalizing them?

17 views
Skip to first unread message

Hermano Cabral

unread,
Jul 3, 2016, 10:20:40 AM7/3/16
to django...@googlegroups.com
Hello guys and gals,

Assuming a simple django project where you have models Author and Book (pseudo code):

Author:
- Name = char field
- Birthdate = date field

Book:
- Name = char field
- Author = foreign key (Author)

Is there a way to freeze books in a way that changes to an author are not propagated to its books? I know I can denormalize the Book model to accomplish that, but I'm looking for another way to do that. I tried using some of the versioning apps out there but none of them work well for my case.

The scenario I have is that some of my models cannot be changed after they are entered into the system, for example, if the "Bible" Book is entered into the system with the Author "Jedus Christ", when someone catches the typo and changes the Author name to "Jesus Christ" the Book "Bible" would still need to have "Jebus Christ" as it's Author.

Thanks.

Sent from my iPhone

Антон Ставинский

unread,
Jul 4, 2016, 1:04:28 PM7/4/16
to Django users
Hello. 
If you changing some fields of Author, books will not changed, except you changed Author.id. 
I think it would be much clear if you will provide some real python example. 
Reply all
Reply to author
Forward
0 new messages