0

After installing and syncing db, i added this to my model:

rating = RatingField(range=5)

and got the error:

Unknown column 'resources_resources.rating_votes' in 'field list'

Docs says: "The way django-ratings is built requires you to attach a RatingField to your models. This field will create two columns, a votes column, and a score column. They will both be prefixed with your field name"

I checked the DB and the tables ratings_score and ratings_vote were created, but no columns were added to the model i added the RatingField to (not sure if it's supposed to add columns to the model's DB).

What am i missing? I believe i followed to tutorial correctly. I'm on Django 1.6. If theres any manual solution to get this working it would help too.

user285943
  • 11
  • 1

1 Answers1

0

Django migrations were only added in Django 1.7, and you are running 1.6.

If you create a new model with a RatingField, then Django will probably create the database columns when you run syncdb. However, there isn't an easy way to add those columns to an existing model.

Note that the GitHub page says that Django ratings is no longer maintained. The last commits were several years ago.

Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • i used python manage.py syncdb exactly as said in the docs. I'm aware that migrate is not available in Django 1.6. If creating the columns on my model's table manually will fix the problem, i'll do so. Just need some more info on these columns. – user285943 Mar 15 '16 at 17:23
  • My point is that syncb will only create the table if it doesn't exist yet, it won't add columns to an existing model. You might find `python manage.py sqlall ` useful when working out how to add the columns manually. – Alasdair Mar 15 '16 at 17:32
  • I checked sqlall and got this: http://paste.ofcode.org/hTTWvpkXkXDFTvfWtbzPJh These 4 tables were also created, but i don't see any hint on how the model's columns would be. – user285943 Mar 15 '16 at 17:46
  • It looks like you ran `sqlall` for the ratings app, not app that you added the ratings field to (`resources`?) – Alasdair Mar 15 '16 at 18:05
  • Oh i get it... sqlall shows the ratings columns: `ratings_votes` integer UNSIGNED NOT NULL and `ratings_score` integer NOT NULL in my model's table. There doesn't seem to be any ForeignKey in the sqlall report, so it means i only need to create these 2 integer columns? – user285943 Mar 15 '16 at 18:22