On Dec 9, 5:02 am, djan <[EMAIL PROTECTED]> wrote: > 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)
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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---