1

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?

0

2 Answers 2

2

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.

1
  • By Deus Harold, you're right! I totally forgot i was not using the development server, i need to restart apache after every change!
    – R0b0tn1k
    Jun 12, 2009 at 21:38
0

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

2
  • 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
    Jun 12, 2009 at 11:08
  • Wouldn't PrName result in the column pr_name? I think we need to see the old model. Jun 12, 2009 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.