Implementing a notes system.

Hey everyone,

So my company is working on a crm software with DRF and NextJS.

We need to implement a notes system to our Meetings model, so I decide to post here to gather some insights from my fellow django devs.

My plan is to create something like this.

class Meeting(models.Model):
    # ...fields
    log = models.OneToOneField(Log)

class Log(models.Model):
    notes = models.ManyToManyField(Note)

class Note(models.Model):
    # ...fields

The idea here, is that a Metting have a Log, that can have multiple notes.

I would appreciate suggestions and experiences from past projects with similar feature.

Thank you guys for your attention.

Does a Meeting have multiple Logs? Can a Log refer to multiple Meetings? If the answer to both those questions is “Yes”, then a ManyToMany is appropriate. Otherwise, the relationship between the two is best described by a ForeignKey. If there’s only one Log for each meeting, and a Log only applies to one meeting, then this relationship is described by a OneToOne relationship, assuming a separate Log object is even required.

As a side note, this is a typical database modelling topic and not specifically a Django-related topic.

Something that’s almost always useful is a trio of timestamps like so:

created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
deleted_at = models.DateTimeField(null=True, db_index=True)

The first two for basic auditing and debugging information, and the third as a basic “soft-delete” system, allowing your users to undo their action fairly easy.