class News(models.Model):
title = models.CharField(maxlength=255, verbose_name="Titre du
billet")
text = models.TextField(verbose_name="Contenu")
keywords = models.CharField(maxlength=255, verbose_name="Mots
clés")
date = models.DateTimeField(verbose_name="Date de publication")
etc.
All is getting well but now (runnin it with MySQL on WebFaction), I
wanted to stick an image with each post, so I added that field to my
News class :
post_image = models.ImageField(upload_to='entetes/', blank=True,
help_text="Doit etre de 300px de large")
But now, I received an error message saying :
(1054, "Unknown column 'news_news.supplementary_image' in 'field
list'")
What's going wrong ?
Thanks a lot :
6TooL9
You'll need to hand-update your table schema. If you run:
./manage.py sql appname
it willl print the new schema. Then you can run:
./manage.py dbshell
and then do:
alter table news.news add [new column definition goes here];
Alternatively, you can dump that table, DROP it, use manage.py syncdb
to re-create it, and then reload the dumped table (minus schema). I
usually use alter table.
I think there are plans to have Django modify existing schemas when
the models change, but it's not implemented yet.
--
This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.
When you change your model, you also have to make changes to your
database to correspond. Django does not currently offer any automatic
facility for this, so you will need to manually write and execute the
appropriate ALTER TABLE statement(s).
--
"May the forces of evil become confused on the way to your house."
-- George Carlin
With webfaction this is easiest to do by using the MysqlAdmin through
their control panel. If you aren't sure what type of field it needs to
be you can run the manage.py sql to get an output of the create table
statements from which you can determine the type of field and other
parameters.
--James
On 9/20/06, Tool69 <kibleur.c...@gmail.com> wrote:
>