Discussion:
OperationalError -- Table has no column named ..
djan
2008-12-09 05:02:07 UTC
Permalink
Hello,

I'm running OpenSuSE-11.0 with the lastest version of django and
sqlite3.
When I enter the admin interface to enter data into my database, I got
the error:

OperationalError at /admin/archive/artist/add/

table archive_artist has no column named salutation

Request Method: POST
Request URL: http://127.0.0.1:8000/admin/archive/artist/add/
Exception Type: OperationalError
Exception Value: table archive_artist has no column named salutation

This error is for the first field of the first table, so I suspect
there is a deeper issue. Perhaps related to this, when I enter the
admin interface, I only see a way to enter records for "Artist", and
not any of the other tables I described below (i.e. "Images",
"Gallery", "On_Loan"). I'm new to database design; perhaps the
relations are off? My models.py looks as follows. Thanks in advance
for any help or suggestions.

class Artist(models.Model):
salutation = models.CharField(max_length=10, blank=True)
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=40)
headshot = models.ImageField(upload_to='/tmp/statement',
blank=True)
statement = models.TextField(blank=True)

def __unicode__(self):
return u'%s %s' % (self.first_name, self.last_name)

class Images(models.Model):
artist = models.ForeignKey(Artist)
file = models.ImageField(upload_to='/tmp/images')
title = models.CharField(max_length=50)
date = models.DateField()

def __unicode__(self):
return u'%s %s' % (self.title, self.date)

class Gallery(models.Model):
images = models.ForeignKey(Images, blank=True)
videos = models.ForeignKey(Videos, blank=True)
name = models.CharField(max_length=40)
address = models.CharField(max_length=30, blank=True)
city = models.CharField(max_length=60, blank=True)
country = models.CharField(max_length=50, blank=True)
phone = models.CharField(max_length=13, blank=True)
email = models.EmailField(blank=True)
website = models.URLField(blank=True)

def __unicode__(self):
return u'%s' % (self.name)

class On_Loan(models.Model):
artist = models.ForeignKey(Artist)
images = models.ManyToManyField(Images, blank=True)
videos = models.ManyToManyField(Videos, blank=True)
location = models.ForeignKey(Gallery)
expiry = models.DateField()

def __unicode__(self):
return u'%s %s' % (self.location, self.expiry)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Daniel Roseman
2008-12-09 09:31:37 UTC
Permalink
Post by djan
Hello,
I'm running OpenSuSE-11.0 with the lastest version of django and
sqlite3.
When I enter the admin interface to enter data into my database, I got
OperationalError at /admin/archive/artist/add/
table archive_artist has no column named salutation
Request Method:         POST
Request URL:    http://127.0.0.1:8000/admin/archive/artist/add/
Exception Type:         OperationalError
Exception Value:        table archive_artist has no column named salutation
This error is for the first field of the first table, so I suspect
there is a deeper issue. Perhaps related to this, when I enter the
admin interface, I only see a way to enter records for "Artist", and
not any of the other tables I described below (i.e. "Images",
"Gallery", "On_Loan"). I'm new to database design; perhaps the
relations are off? My models.py looks as follows. Thanks in advance
for any help or suggestions.
    salutation = models.CharField(max_length=10, blank=True)
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=40)
    headshot = models.ImageField(upload_to='/tmp/statement',
blank=True)
    statement = models.TextField(blank=True)
        return u'%s %s' % (self.first_name, self.last_name)
    artist = models.ForeignKey(Artist)
    file = models.ImageField(upload_to='/tmp/images')
    title = models.CharField(max_length=50)
    date = models.DateField()
        return u'%s %s' % (self.title, self.date)
    images = models.ForeignKey(Images, blank=True)
    videos = models.ForeignKey(Videos, blank=True)
    name = models.CharField(max_length=40)
    address = models.CharField(max_length=30, blank=True)
    city = models.CharField(max_length=60, blank=True)
    country = models.CharField(max_length=50, blank=True)
    phone = models.CharField(max_length=13, blank=True)
    email = models.EmailField(blank=True)
    website = models.URLField(blank=True)
        return u'%s' % (self.name)
    artist = models.ForeignKey(Artist)
    images = models.ManyToManyField(Images, blank=True)
    videos = models.ManyToManyField(Videos, blank=True)
    location = models.ForeignKey(Gallery)
    expiry = models.DateField()
        return u'%s %s' % (self.location, self.expiry)
The problem isn't with your model structure (although there is one
issue there, see below), but with your database tables. Most probably,
you set up your database and ran manage.py syncdb, then made some
changes to your models afterwards. Django does *not* change existing
database tables when you edit the models - you need to do this
yourself, usually via SQL. Since you're running sqlite and you haven't
added any data yet, the easiest thing to do is delete your database
file and run syncdb again.

Your second problem, the lack of links to edit other tables, depends
on your admin.py file which you haven't posted. You just need to
remember to register in the admin every model you want to edit there.
If you're still having problems there, post your admin.py and we'll
try to help.

Finally, your model layout itself. It looks good except for one issue
- the relationship between Gallery and Images. You have a Foreign Key
from Gallery to Images, which means that each gallery has only one
image, and each image can belong to multiple galleries. I suspect you
didn't mean that... most likely you want this to be the other way
round, with the ForeignKey field on Images pointing to Gallery (and
the same for Videos, which you haven't posted).

--
DR.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
djan
2008-12-09 18:43:47 UTC
Permalink
Thanks so much for the help! I deleted the database, made the changes
you suggested and ran syncdb again. I have two lingering issues.

1) At the django admin interface, I still only see a place to enter
data for 'Artist', and none of the tables that follow it in models.py
appear (the updated version appears below).

2) I was able to enter data into all the fields of 'Artist' table
without a problem--except for the image field.
SuspiciousOperation at /admin/archive/artist/1/
Attempted access to '/tmp/statement/headshot.jpg' denied.

Request Method: POST
Request URL: http://127.0.0.1:8000/admin/archive/artist/1/
Exception Type: SuspiciousOperation
Exception Value: Attempted access to '/tmp/statement/headshot.jpg'
denied.

I think I remember reading that it could have something to do with a
missing (or present, in this case) '/' before the upload_to argument.
I will look into that.from django.db import models

class Artist(models.Model):
salutation = models.CharField(max_length=10, blank=True)
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=40)
address = models.CharField(max_length=30, blank=True)
city = models.CharField(max_length=60, blank=True)
country = models.CharField(max_length=50, blank=True)
phone = models.CharField(max_length=13, blank=True)
email = models.EmailField(blank=True)
website = models.URLField(blank=True)
headshot = models.ImageField(upload_to='/tmp/statement',
blank=True)
statement = models.TextField(blank=True)

def __unicode__(self):
return u'%s %s' % (self.first_name, self.last_name)

class Gallery(models.Model):
name = models.CharField(max_length=40)
address = models.CharField(max_length=30, blank=True)
city = models.CharField(max_length=60, blank=True)
country = models.CharField(max_length=50, blank=True)
phone = models.CharField(max_length=13, blank=True)
email = models.EmailField(blank=True)
website = models.URLField(blank=True)

def __unicode__(self):
return u'%s' % (self.name)

class Images(models.Model):
artist = models.ForeignKey(Artist)
gallery = models.ForeignKey(Gallery, blank=True)
file = models.ImageField(upload_to='/tmp/images')
title = models.CharField(max_length=50)
date = models.DateField()

def __unicode__(self):
return u'%s %s' % (self.title, self.date)

class Videos(models.Model):
artist = models.ForeignKey(Artist)
gallery = models.ForeignKey(Gallery, blank=True)
file = models.FileField(upload_to='/tmp/videos')
title = models.CharField(max_length=50)
date = models.DateField()

def __unicode__(self):
return u'%s %s' % (self.title, self.date)

class Sale_Item(models.Model):
artist = models.ForeignKey(Artist)
images = models.ManyToManyField(Images, blank=True)
videos = models.ManyToManyField(Videos, blank=True)
price = models.CharField(max_length=10)

def __unicode__(self):
return u'%s' % (self.price)

class On_Loan(models.Model):
artist = models.ForeignKey(Artist)
images = models.ManyToManyField(Images, blank=True)
videos = models.ManyToManyField(Videos, blank=True)
location = models.ForeignKey(Gallery)
expiry = models.DateField()

def __unicode__(self):
return u'%s %s' % (self.location, self.expiry)
Post by Daniel Roseman
Post by djan
Hello,
I'm running OpenSuSE-11.0 with the lastest version of django and
sqlite3.
When I enter the admin interface to enter data into my database, I got
OperationalError at /admin/archive/artist/add/
table archive_artist has no column named salutation
Request Method:         POST
Request URL:    http://127.0.0.1:8000/admin/archive/artist/add/
Exception Type:         OperationalError
Exception Value:        table archive_artist has no column named salutation
This error is for the first field of the first table, so I suspect
there is a deeper issue. Perhaps related to this, when I enter the
admin interface, I only see a way to enter records for "Artist", and
not any of the other tables I described below (i.e. "Images",
"Gallery", "On_Loan"). I'm new to database design; perhaps the
relations are off? My models.py looks as follows. Thanks in advance
for any help or suggestions.
    salutation = models.CharField(max_length=10, blank=True)
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=40)
    headshot = models.ImageField(upload_to='/tmp/statement',
blank=True)
    statement = models.TextField(blank=True)
        return u'%s %s' % (self.first_name, self.last_name)
    artist = models.ForeignKey(Artist)
    file = models.ImageField(upload_to='/tmp/images')
    title = models.CharField(max_length=50)
    date = models.DateField()
        return u'%s %s' % (self.title, self.date)
    images = models.ForeignKey(Images, blank=True)
    videos = models.ForeignKey(Videos, blank=True)
    name = models.CharField(max_length=40)
    address = models.CharField(max_length=30, blank=True)
    city = models.CharField(max_length=60, blank=True)
    country = models.CharField(max_length=50, blank=True)
    phone = models.CharField(max_length=13, blank=True)
    email = models.EmailField(blank=True)
    website = models.URLField(blank=True)
        return u'%s' % (self.name)
    artist = models.ForeignKey(Artist)
    images = models.ManyToManyField(Images, blank=True)
    videos = models.ManyToManyField(Videos, blank=True)
    location = models.ForeignKey(Gallery)
    expiry = models.DateField()
        return u'%s %s' % (self.location, self.expiry)
The problem isn't with your model structure (although there is one
issue there, see below), but with your database tables. Most probably,
you set up your database and ran manage.py syncdb, then made some
changes to your models afterwards. Django does *not* change existing
database tables when you edit the models - you need to do this
yourself, usually via SQL. Since you're running sqlite and you haven't
added any data yet, the easiest thing to do is delete your database
file and run syncdb again.
Your second problem, the lack of links to edit other tables, depends
on your admin.py file which you haven't posted. You just need to
remember to register in the admin every model you want to edit there.
If you're still having problems there, post your admin.py and we'll
try to help.
Finally, your model layout itself. It looks good except for one issue
- the relationship between Gallery and Images. You have a Foreign Key
from Gallery to Images, which means that each gallery has only one
image, and each image can belong to multiple galleries. I suspect you
didn't mean that... most likely you want this to be the other way
round, with the ForeignKey field on Images pointing to Gallery (and
the same for Videos, which you haven't posted).
--
DR.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Loading...