Answer the question
In order to leave comments, you need to log in
What is the best way to make history model in Django?
Hey!
Background : a small django service parses resources, receives objects that need to be filtered according to different criteria, sequentially, leaving only suitable ones. There are many resources, there are many objects on the resources, there are about 5-7 criteria (filters).
Task : I wanted to keep a detailed log (and not just in the filter.log file) so that I could analyze which filters in which resources filter information most often and how often.
For this, a simple model was created:
class FilterHistory(models.Model):
created_at = models.DateTimeField(auto_now_add=True, editable=False)
source = models.ForeignKey(Source, on_delete=models.CASCADE, related_name='history')
filter_name = models.CharField(max_length=100, default='unknown')
filtered_number = models.IntegerField()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question