0
from django.db import models
from imagekit.models import ImageSpecField
from imagekit.processors import ResizeToFill

class Product(models.Model):

class Meta():
    db_table = 'tovar'


product_title = models.CharField(max_length=200)
product_img = models.ImageField(upload_to='images')
avatar = models.ImageField(upload_to='avatars')
avatar_thumbnail = ImageSpecField(source='avatar',processors=[ResizeToFill(100, 50)],format='JPEG',options={'quality': 60})
product_categories = models.ForeignKey(Category)
product_subcategories = models.ForeignKey(Subcategory)
product_description = models.TextField()


def __unicode__(self):
    return self.product_title


profile = Product.objects.all()[0]
print(profile.avatar_thumbnail.url)    
print(profile.avatar_thumbnail.width)  

Dont working manage.py syncdb

Error:

django.db.utils.OperationalError: no such table: tovar

pls healp me

Dimon Kudimon
  • 53
  • 3
  • 7

3 Answers3

2

'python manage.py syncdb' doesn't work for Django 1.9 or later, try this code!

  • python manage.py makemigrations

  • python manage.py migrate

  • python manage.py migrate --run-syncdb

I have the same problem with Django 1.9 and 1.10. This code works!

T.T
  • 1,011
  • 1
  • 7
  • 6
0

If you have modified your model you first have to run

manage.py schemamigration your_django_application_name --auto

Then you run:

manage.py migrate your_django_application_name

lapinkoira
  • 8,320
  • 9
  • 51
  • 94
  • No, the command to create a migration is `makemigrations`, and it doesn't have an `--auto` flag. – Daniel Roseman Mar 23 '15 at 16:29
  • That's why I said at the beginning "If you have modified your model you first have to run" If he is initializing the app he could run `manage.py schemamigration your_django_application_name --initial` And then migrate as said in the south documentation http://south.readthedocs.org/en/latest/tutorial/part1.html – lapinkoira Mar 23 '15 at 16:36
  • But why are you recommending South? Migrations are now built into Django, there is no indication that OP is using an old version. – Daniel Roseman Mar 23 '15 at 16:37
  • Not any indication at all he was using migrations that's why I suggested he could check them this way. – lapinkoira Mar 23 '15 at 16:47
0

use the below command

>>python manage.py sqlmigrate  application_name 0001

if you have more tables then increment the number to ooo2 and run the abe code again

>>python manage.py runserver
celroy
  • 11
  • 3