That's my models.py:
class User(models.Model):
email = models.EmailField()
def __unicode__(self):
return str(self.email)
class Link(models.Model):
link = models.URLField()
users = models.ManyToManyField(User, through='ShortURL')
class ShortURL(models.Model):
link = models.ForeignKey(Link)
user = models.ForeignKey(User)
short_end = models.CharField(max_length=20)
counter = models.IntegerField()
adding users works just fine:
>>> user = User.objects.create("john_doe@planetearth.com")
I get integrity error when I try to add link:
>>> link = Link.objects.create("stackoverflow.com")
IntegrityError: shortener_link.short_end may not be NULL
What am I missing?