Django says the "id may not be NULL" but why is it?
        Posted  
        
            by Oli
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Oli
        
        
        
        Published on 2010-03-29T14:43:55Z
        Indexed on 
            2010/03/29
            15:03 UTC
        
        
        Read the original article
        Hit count: 342
        
I'm going crazy today. I just tried to insert a new record and it threw back a "post_blogpost.id may not be NULL" error. Here's my model:
class BlogPost(models.Model):
    title   = models.CharField(max_length=100)
    slug    = models.SlugField(max_length=100)
    who     = models.ForeignKey(User, default=1)
    when    = models.DateTimeField()
    intro   = models.TextField(blank=True, null=True)
    content = models.TextField(blank=True, null=True)
    counter = models.PositiveIntegerField(default=0)
    published = models.BooleanField(default=False)
    css = models.TextField(blank=True, null=True)
    class Meta:
        ordering = ('-when', 'id')
There are a number of functions beneath the model too but I won't include them in full here. Their names are: content_cache_key, clear_cache, __unicode__, reads, read, processed_content.
I'm adding through the admin... And I'm running out of hair.
© Stack Overflow or respective owner