Question

Have not been able to find a solution for this.

models.py

class Product(models.Model):
    prod_id = models.IntegerField(primary_key = True)
    prod_name = models.CharField(max_length=128)
    prod_price = models.FloatField()
    prod_quantity = models.CharField(max_length=75)
    prod_description = models.TextField()
    prod_attributes = models.TextField()
    prod_ingredients = models.TextField()

settings.py

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'MyApp',

This is the error that's thrown:

Creating tables ... self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python27\Lib\site-packages\django\core\management\base.py", line 196, in run_from_argv self.execute(*args, **options.dict) File "C:\Python27\Lib\site-packages\django\core\management\base.py", line 232, in execute output = self.handle(*args, **options) File "C:\Python27\Lib\site-packages\django\core\management\base.py", line 371, in handle return self.handle_noargs(**options) File "C:\Python27\Lib\site-packages\django\core\management\commands\syncdb.py", line 91, in handle_noargs sql, references = connection.creation.sql_create_model(model, self.style, seen_models) File "C:\Python27\Lib\site-packages\django\db\backends\creation.py", line 82, in sql_create_model style.SQL_TABLE(qn(opts.db_table)) + ' ('] File "C:\Python27\Lib\site-packages\django\db\backends\mysql\base.py", line 244, in quote_name if name.startswith("") and name.endswith(""): AttributeError: 'list' object has no attribute 'startswith'

So the key part: AttributeError: 'list' object has no attribute 'startswith'

Anybody have any ideas as to why I'm getting this error? I've tried alot of different things and it just wont work even thou it creates the other tables successfully it just won't create my model classes. I am using a mysql database.

Was it helpful?

Solution

The traceback suggests that you may have used the db_table option incorrectly. It should be a string, not a list. Please check your usage, and update your question with more code if you are not sure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top