I'm currently working on my first Django project and have hit a roadblock in regard to adding an ImageField to an existing model.
I currently have a model for a user posting content and one for django- profiles. For the former, I added an ImageField so the used can submit a photo to accompany the text content. For the latter, I want to allow users to upload a profile photo (not worried at the moment about avatar resizing). Things were working well until I added ImageFields to both models. I then synced the database with South. What resulted when I try to pull up the once working templates for profiles is: "no such column: report_userprofile.profile_pic" A similar error occurs when trying to view the submitted text content. I set both of the fields to "blank=True" so it seemed as if not having an image file would not cause an error. I'm obviously wrong. I did not initially put these fields in the models, which in hindsight was a big mistake. I've also just set up the MEDIA_ROOT and MEDIA_URL as follows: MEDIA_ROOT = 'os.path.join(BASE_DIR, "media")' MEDIA_URL = 'http://localhost:8000/media' The models I'm now using are: class Story(models.Model): title = models.CharField(max_length=100) topic = models.CharField(max_length=50) copy = models.TextField() author = models.ForeignKey(User) zip_code = models.CharField(max_length=10) latitude = models.FloatField(blank=False, null=False) longitude = models.FloatField(blank=False, null=False) date = models.DateTimeField(auto_now=True, auto_now_add=True) pic = models.ImageField(upload_to='pictures', blank=True) def __unicode__(self): return " %s" % (self.title) class UserProfile(models.Model): user = models.ForeignKey(User, unique=True) first_name = models.CharField(max_length=25) last_name = models.CharField(max_length=35) email = models.EmailField() birth_date = models.DateField(blank=True, null=True) city = models.CharField(max_length=25) state = models.CharField(max_length=20) zip_code = models.CharField(max_length=10) profile_pic = models.ImageField(upload_to='pictures', blank=True) The accompanying forms for submission: class ProfileForm(forms.ModelForm): class Meta: model = UserProfile class StoryForm(forms.ModelForm): class Meta: model = Story exclude = ('author',) The URLs file is set up as follows: url(r'^admin/', include(admin.site.urls)), (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}, The core problem here is I have no idea what the error(s) might be (the previous templates aren't set up properly since there was no ImageField in the existing form for input? i didn't set up the MEDIA_ROOT and URL earlier?). Or better yet, errors, as I'm sure I've made several. It's a bit of a soup right now along with the resulting distress. Just as an FYI, I have installed the PIL. Part of the issue may be that when I used South to add these fields it didn't appear to migrate properly (I posted earlier about possibly wiping the sqlite3 clean and starting from scratch). But I tried the files on another computer without the potentially erroneous database and the same error resulted. Any insight at all, even a small insight, into what I need to do to remedy this situation would be beyond appreciated. I've searched for similar issues but none this specific emerges. (The first lesson for the future would be to obviously set up the ImageFiles when initially assembling the models.) Usually I can figure things out by researching previous questions or making a basic inquiry, but this time I'm in a hole. Hopefully, i can learn from this episode. Many thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.