Non-database field in Django model

As long as you do not want the property to persist, I don’t see why you can’t create a property like you described. I actually do the same thing on certain models to determine which are editable.

class Email(EntryObj):
    ts = models.DateTimeField(auto_now_add=True)
    body = models.TextField(blank=True)
    user = models.ForeignKey(User, blank=True, null=True)
    editable = False
    ...


class Note(EntryObj):
    ts = models.DateTimeField(auto_now_add=True)
    note = models.TextField(blank=True)
    user = models.ForeignKey(User, blank=True, null=True)
    editable = True

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)