tags:

views:

47

answers:

2

I changed the model, synced the db, and now when i do:

Prs = Products.objects.filter(PrName__icontains='bla')

I get the error:

    ERROR:  column search_products.pr_name does not exist
LINE 1: SELECT "search_products"."id", "search_products"."pr_name", ...

But pr_name was the old model, this is how the new model looks like:

class Products(models.Model):
  PrName = models.CharField(max_length=255)
  PrDescription = models.CharField(max_length=4000)
  PrPrice = models.DecimalField(max_digits=5, decimal_places=2)
  PrCompany =  models.ForeignKey(Companies)

  def __str__(self):
    return self.PrName

Why am i getting this error? I synced the db 100 times, checked all the code, there is no reference to pr_name anywhere?

A: 

Unfortunately the thing you try to do is not supported by django out of the box :-(

but you can do it ether by adding a db_column to the fields or by exporting the data, removing the table from the database, edit the export file, recreate the database table and reimporting the data.

Also look at the various schema evolution solutions out there

Mr Shark
His problem isn't a new field that needs migration, but rather his error indicates an old field (one no longer in the models) is being queried and not in database (i.e. syncdb worked properly).
Van Gale
Wouldn't PrName result in the column pr_name? I think we need to see the old model.
Dominic Rodger
+2  A: 

Have you tried restarting your server? If you are using anything other than the development server, you'll probably need to do that manually after making changes like this.

Harold
By Deus Harold, you're right!I totally forgot i was not using the development server, i need to restart apache after every change!