Answer the question
In order to leave comments, you need to log in
Why is the _id may not be null error thrown?
I want to make a rating, and for this I added the voted_by field to keep track of those who voted. The migrations went fine, but an exception is thrown: base_record.voted_by_id may not be NULL .
Model:
class Record(models.Model):
title = models.CharField(max_length=128)
author = models.ForeignKey(UserProfile,related_name='record')
voted_by = models.ForeignKey(UserProfile,related_name='voted_by',blank=True)
description = models.CharField(max_length=128)
duration = models.IntegerField(default=0)
likes = models.IntegerField(default=0)
rating = models.FloatField(default=0)
price = models.DecimalField(max_digits=10,decimal_places=2,default=0)
file = models.FileField()
def __unicode__(self):
return self.title
Answer the question
In order to leave comments, you need to log in
When is it thrown out? It would be nice to see the entire stack trace. I suspect that instead of blank=True in the parameters of the voted_by field, you should write null=True.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question