Re: Adding a decorator to include a property in an object's serialization

2021-06-08 Thread 'Adam Johnson' via Django developers (Contributions to Django itself)
Hi Diptesh Django's serialization framework is mostly used for saving model data for later loading into the DB - normally for setting up environments or tests. I don't think saving properties is useful in this case. If you're using serialization for API responses, look at Django REST Framework's s

Adding a decorator to include a property in an object's serialization

2021-06-07 Thread Diptesh Choudhuri
Hello, I hope you are all doing well. Currently if one wants to have custom properties on their models without introducing new columns, they have to use properties: class Chapter(models.Model): name = models.CharField() text = models.TextField() @property def word_count(self):