I just added a FileField to my Model (thumbnail = 
models.FileField(upload_to=get_upload_file_name), however when I try to use 
South to migrate the model, I get a message telling me . . . "The field 
'Article.thumbnail' does not have a default specified, yet is NOT NULL. 
Since you are adding this field, you MUST specify a default
value to use for existing rows. Would you like to: 1. Quit now, and add a 
default to the field in models.py 2. Specify a one-off value to use for 
existing columns now
Please select a choice: " . . .I chose option #2 and used 
"datetime.datetime.now". . .

When I began googling this I found a ticket (#10244) that doesn't seem to 
be resolved. Several questions concerning this on Stack Overflow suggest 
using "blank=True" as a default. Another says use "blank=True" AND 
"null=True". The ticket says "null=True" doesn't do anything. . .Anyways, I 
tried both and nothing seemed to change. When I tried a migration, it told 
me there were no changes (after I added each "blank=True" AND "null=True". 
. .

My question is, has there been any resolution to this? What am I supposed 
to use in this situation? Please see the Model below. .Any help would be 
greatly appreciated. Thanks in advance!

#Models.py below. . .

def get_upload_file_name(inatance, filename):
    return "uploaded_files/%s_%s" % (str(time()).replace('.','_'), filename)


# Create your models here.
class Article(models.Model):
    title = models.CharField(max_length=200)
    body = models.TextField()
    pub_date = models.DateTimeField('date published')
    likes = models.IntegerField(default=0)
    thumbnail = models.FileField(upload_to=get_upload_file_name, 
blank=True, null=True)

    
    def __unicode__(self):
        return self.title

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to