Opened 11 years ago

Closed 11 years ago

#13183 closed (invalid)

db_table case sensitive

Reported by: noppes Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I have the model:

class UserProfile(models.Model):
    user = models.ForeignKey(User)

    class Meta:
        db_table = "UserProfile"

and when i run syncdb for a second time i get this error:

python syncdb
Creating table UserProfile
Traceback (most recent call last):
  File "", line 11, in <module>
  File "D:\Python26\lib\site-packages\django\core\management\", line
438, in execute_manager
  File "D:\Python26\lib\site-packages\django\core\management\", line
379, in execute
  File "D:\Python26\lib\site-packages\django\core\management\", line 196,
 in run_from_argv
    self.execute(*args, **options.__dict__)
  File "D:\Python26\lib\site-packages\django\core\management\", line 223,
 in execute
    output = self.handle(*args, **options)
  File "D:\Python26\lib\site-packages\django\core\management\", line 352,
 in handle
    return self.handle_noargs(**options)
  File "D:\Python26\lib\site-packages\django\core\management\commands\"
, line 94, in handle_noargs
  File "D:\Python26\lib\site-packages\django\db\backends\", line 19, in e
    return self.cursor.execute(sql, params)
  File "D:\Python26\lib\site-packages\django\db\backends\mysql\", line 86
, in execute
    return self.cursor.execute(query, args)
  File "D:\Python26\lib\site-packages\MySQLdb\", line 173, in execute
    self.errorhandler(self, exc, value)
  File "D:\Python26\lib\site-packages\MySQLdb\", line 36, in defau
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1050, "Table 'userprofile' already exists")

my guess is that this is a case problem.

first time I ran syncdb it said: Creating table UserProfile, but it actually created userprofile in lower case.

when i change db_table = "UserProfile" to db_table = "userprofile" i dont get the error
but I ofcourse want my database tables with capital letters

Change History (1)

comment:1 Changed 11 years ago by Karen Tracey

Resolution: invalid
Status: newclosed

I believe this is a configuration problem with your MySQL installation, see:, not a Django bug.

Note: See TracTickets for help on using tickets.
Back to Top