This is my simple Django database model. It's for a 5-star rating system.
class Rating(models.Model):
content = models.OneToOneField(Content, primary_key=True)
ip = models.CharField(max_length=200, blank=True)
rating = models.IntegerField(default=0)
As you can see, it is linked to "Content", which is the table for my documents. My question is:
- How do I make content+ip unique...so that it multiple content is okay, but multiple content AND IP is not okay (do not want the user to rate twice).
- How do I create a data-base index for content and ip...because I will always be selecting those (to compare if it is already in the database).