Syncdb not working

2.7k Views Asked by At
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

3

There are 3 best solutions below

4
lapinkoira On

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

0
celroy On

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
0
T.T On

'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!