[Answered ]-What do you think about my Django model structure?

2👍

How about this: define a type of post so you can have many more types of post in the future, and a UserBookmark so a user can have as many bookmarks he wants:

class UserProfile(models.Model):
    # its a good practice from django
    user = OneToOneField(User, primary_key=True)

class Post(models.Model):
    P_TYPE_1 = 1
    P_TYPE_2 = 2
    TAB_P_TYPE = {
        P_TYPE_1: _("Type 1"),
        P_TYPE_2: _("Type 2"),
    }
    post_type = models.IntegerField(
        choices=[(a, b) for a, b in list(TAB_P_TYPE.items())],
        default=P_TYPE_1)
    text = models.TextField(max_length=110)

class UserPostBookmark(models.Model):
    user = models.ForeignKey(UserProfile)
    post = models.ForeignKey(Post)

Leave a comment