Related
I am trying to unitest my models in my django application that consisits of some migrations. I have prepared my test, but when running
./manage.py test my_app
i get the following error
django.db.utils.OperationalError: (1005, "Can't create table 'test_rhombusdb.#sql-4ca_2c' (errno: 150)")
The database is created normally, So I guess I have permissions to create the db.
I really don't know which table this is reffering to. Migrations pass normal and db works fine in production. What could be the issue here?
what other info would you like?
my stack trace
File "./manage.py", line 18, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 30, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 74, in execute
super(Command, self).execute(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 444, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 90, in handle
failures = test_runner.run_tests(test_labels)
File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line 210, in run_tests
old_config = self.setup_databases()
File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line 166, in setup_databases
**kwargs
File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line 370, in setup_databases
serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/creation.py", line 368, in create_test_db
test_flush=not keepdb,
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 120, in call_command
return command.execute(*args, **defaults)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 444, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 179, in handle
created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 317, in sync_apps
cursor.execute(statement)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)
File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 205, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.OperationalError: (1005, "Can't create table 'testdb.#sql-4ca_7c' (errno: 150)")
I can see there is an error when migration is called.
PS: I droped my database(real one but the developement one) and tried to recreate tables running migrate. I came with the same error. Running migrate again worked like a charm....Something is really really really wrong here....
PS2: Deleting all migration folders and starting without gave me the same error after running migrate with no migration folders present....Very bad error very difficult to debug
PS3: There is an issue with the foreign key on one (at least so far i've tested) of my models. I tried deactivating apps and activating them in terms, and when I got to a specific one, error occured.I isolated one model, and gave me the issue. I commented out the foreign keys and worked. Uncomment one of them error again.
class Patient(models.Model):
#many fields here
doctor = models.ForeignKey(settings.AUTH_USER_MODEL, related_name="patients")
It worked with 1.6 and sqlite3, I moved to 1.8 and mysql, and boom...error.
AUTH_USER_MODEL = 'users.MyCustomUser'
MyCustomUser is a class inheriting AbstractBaseUser and PermissionsMixin.
I had the same (pretty general) error message. For me it came down to having forgot to run makemigrations on a new app. See also:
https://docs.djangoproject.com/en/1.8/topics/migrations/#dependencies
I use django_celery with connecting to Amazon Redshift. To migrate database, after "makemigrations" I used command "python manage.py migrate" and error message show up as shown below.
The reason is Redshift does not support data type 'serial' but the 'django_migrations' table that contain 'serial' type is automatically created.
How to stop Django Migrations create this table or avoid using serial on 'django_migrations' table.
D:\code\test_celery_django>python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 338, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 441, in execute
output = self.handle(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\migrate.py", line 93, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", line 19, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", line 47, in __init__
self.build_graph()
File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", line 180, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 59, in applied_migrations
self.ensure_schema()
File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 53, in ensure_schema
editor.create_model(self.Migration)
File "C:\Python27\lib\site-packages\django\db\backends\base\schema.py", line 286, in create_model
self.execute(sql, params or None)
File "C:\Python27\lib\site-packages\django\db\backends\base\schema.py", line 111, in execute
cursor.execute(sql, params)
File "C:\Python27\lib\site-packages\django\db\backends\utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "C:\Python27\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Python27\lib\site-packages\django\db\utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Python27\lib\site-packages\django\db\backends\utils.py", line 62, in execute
return self.cursor.execute(sql)
django.db.utils.NotSupportedError: Column "django_migrations.id" has unsupported type "serial".
Are you trying to use Redshift as the backend database for your web application? That's a bad idea, Redshift is a data warehouse and as such individual query performance and latency are far from great, not to mention that Redshift doesn't enforce primary keys, which almost surely Django expects.
My recommendation, use PostgreSQL.
I have a problem with Django quite incomprehensible.
I used models.py to model my database. This database runs on the production server. I want to change it, so I create a new database on the development server. The problem happens when I do syncdb, Django tries to create twice the same table, as you can see below:
python manage.py syncdb
Operations to perform:
Synchronize unmigrated apps: inventaryApp, newPrpvApp, grappelli, debug_toolbar, registration, import_export
Apply all migrations: sitetree, sessions, admin, sites, auth, contenttypes
Synchronizing apps without migrations:
Creating tables...
Creating table u_institutions
Creating table u_users
Creating table o_organes
Creating table o_degats
Creating table o_validation
Creating table o_m_determination
Creating table o_stades_dvlpmt
Creating table o_types
Creating table precision_date
Creating table t_categories
Creating table t_etat_synonymie
Creating table g_langues
Creating table g_pays
Creating table g_regions
Creating table g_communes
Creating table pays_langues
Creating table newprpvapp_userprofile
Creating table t_noms_verna
Creating table langues_noms_verna
Creating table maladies
Creating table t_familles
Creating table t_genres
Creating table t_especes
Creating table images
Creating table esp_noms_verna
Creating table t_infra_types
Creating table t_infra_sp
Creating table t_synonymes
Creating table o_contexte
Creating table o_interception
Creating table o_hotes
Creating table hotes_organes
Creating table o_organismes_associes
Creating table u_institutions
As you can see, the u_institutions table is created the first, but also at the end. And this is where the execution of the command stops to show:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/base.py", line 533, in handle
return self.handle_noargs(**options)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 27, in handle_noargs
call_command("migrate", **options)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 115, in call_command
return klass.execute(*args, **defaults)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 128, in handle
created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 239, in sync_apps
cursor.execute(statement)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 63, in execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "u_institutions" already exists
I have verified that the table had not been set twice in model.py, and it was not. I use Django 1.7, and psycopg 2.6. Do you have an idea please? Thank you all!
Edit
I had already executed makemigrations, and everything was good. Now it indicates that no change is detected, which is probably normal.
When I try migrate, I get :
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 128, in handle
created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 239, in sync_apps
cursor.execute(statement)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 63, in execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "u_institutions" already exists
And migrate --fake return :
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 128, in handle
created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 239, in sync_apps
cursor.execute(statement)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/hugo/DEV/.virtualenvs/env_eprpv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 63, in execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "u_institutions" already exists
It seems that you have already created your database schema. Please, use migration (as long as you use Django 1.7). syncdb is deprecated.
python manage.py makemigrations
python manage.py migrate
If you will face any errors here (like relation "..." already exists) run this command to mark this tables as applied:
python manage.py migrate --fake
Im trying to write simple application with this project structure:
website (root directory)
..mainws (its app)
....migrations(not filled)
....usermodels
......__init__.py
......Role.py
....__init__.py
....admin.py
....models.py
....test.py
....views.py
..website(directory for project)
..manage.py
And after making project, I created mainws app, when wrote for Role table. Also added in models.py (directory mainws):
from usermodels import Role
But using in terminal "manage.py sqlall mainws" giving for me big stacktrace (mainws app added at the and of INSTALLED_APPS). How can I fix this trouble?
Role.py contains code:
from django.db import models
class Role(models.Model):
role_name = models.CharField(max_length=25)
def GetRoleName(self):
return self.role_name
def SetRoleName(self, new_role_name):
if self.role_name != new_role_name:
self.role_name = new_role_name
Stacktrace:
=> python manage.py sqlall mainws
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/core/management/base.py", line 449, in handle
app_output = self.handle_app_config(app_config, **options)
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/core/management/commands/sqlall.py", line 25, in handle_app_config
statements = sql_all(app_config, self.style, connection)
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/core/management/sql.py", line 174, in sql_all
check_for_migrations(app_config, connection)
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/core/management/sql.py", line 18, in check_for_migrations
loader = MigrationLoader(connection)
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/db/migrations/loader.py", line 48, in __init__
self.build_graph()
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/db/migrations/loader.py", line 179, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 59, in applied_migrations
self.ensure_schema()
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 53, in ensure_schema
editor.create_model(self.Migration)
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/db/backends/schema.py", line 263, in create_model
self.execute(sql, params)
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/db/backends/schema.py", line 99, in execute
cursor.execute(sql, params)
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/savicvalera/code/lab8/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: no schema has been selected to create in
Do the following changes :
1) Rename your usermodels folder to models folder(for simplicity).
2) In the __init__.py file of models folder, import the Role model using from . import Role.
3) leave the models.py file(of the outer directory) blank.
So ultimately you will have the following structure
website (root directory)
..mainws (its app)
....migrations(not filled)
....models
......__init__.py
......Role.py
....__init__.py
....admin.py
....models.py
....test.py
....views.py
..website(directory for project)
..manage.py
Then run the sqlall command.It should work!
Sorry for this type of silly question. I am a noob into Django. I was following Django Official tutorial and At the stage of python3 manage.py syncdb i got this huge error
Creating tables ...
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Traceback (most recent call last):
File "/usr/local/lib/python3.3/dist-packages/django/contrib/contenttypes/models.py", line 39, in get_for_model
ct = self._get_from_cache(opts)
File "/usr/local/lib/python3.3/dist-packages/django/contrib/contenttypes/models.py", line 29, in _get_from_cache
return self.__class__._cache[self.db][key]
KeyError: 'default'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.3/dist-packages/django/db/backends/util.py", line 46, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.3/dist-packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)
File "/usr/local/lib/python3.3/dist-packages/MySQL_python-1.2.3-py3.3-linux-x86_64.egg/MySQLdb/cursors.py", line 184, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python3.3/dist-packages/MySQL_python-1.2.3-py3.3-linux-x86_64.egg/MySQLdb/connections.py", line 37, in defaulterrorhandler
raise errorvalue
File "/usr/local/lib/python3.3/dist-packages/MySQL_python-1.2.3-py3.3-linux-x86_64.egg/MySQLdb/cursors.py", line 171, in execute
r = self._query(query)
File "/usr/local/lib/python3.3/dist-packages/MySQL_python-1.2.3-py3.3-linux-x86_64.egg/MySQLdb/cursors.py", line 330, in _query
rowcount = self._do_query(q)
File "/usr/local/lib/python3.3/dist-packages/MySQL_python-1.2.3-py3.3-linux-x86_64.egg/MySQLdb/cursors.py", line 294, in _do_query
db.query(q)
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s AND `django_content_type`.`app_label` = %s )' at line 1")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.3/dist-packages/django/core/management/__init__.py", line 397, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.3/dist-packages/django/core/management/__init__.py", line 390, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.3/dist-packages/django/core/management/base.py", line 240, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python3.3/dist-packages/django/core/management/base.py", line 283, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.3/dist-packages/django/core/management/base.py", line 413, in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python3.3/dist-packages/django/core/management/commands/syncdb.py", line 112, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "/usr/local/lib/python3.3/dist-packages/django/core/management/sql.py", line 216, in emit_post_sync_signal
interactive=interactive, db=db)
File "/usr/local/lib/python3.3/dist-packages/django/dispatch/dispatcher.py", line 182, in send
response = receiver(signal=self, sender=sender, **named)
File "/usr/local/lib/python3.3/dist-packages/django/contrib/auth/management/__init__.py", line 82, in create_permissions
ctype = ContentType.objects.db_manager(db).get_for_model(klass)
File "/usr/local/lib/python3.3/dist-packages/django/contrib/contenttypes/models.py", line 47, in get_for_model
defaults = {'name': smart_text(opts.verbose_name_raw)},
File "/usr/local/lib/python3.3/dist-packages/django/db/models/manager.py", line 154, in get_or_create
return self.get_queryset().get_or_create(**kwargs)
File "/usr/local/lib/python3.3/dist-packages/django/db/models/query.py", line 373, in get_or_create
return self.get(**lookup), False
File "/usr/local/lib/python3.3/dist-packages/django/db/models/query.py", line 301, in get
num = len(clone)
File "/usr/local/lib/python3.3/dist-packages/django/db/models/query.py", line 77, in __len__
self._fetch_all()
File "/usr/local/lib/python3.3/dist-packages/django/db/models/query.py", line 856, in _fetch_all
self._result_cache = list(self.iterator())
File "/usr/local/lib/python3.3/dist-packages/django/db/models/query.py", line 220, in iterator
for row in compiler.results_iter():
File "/usr/local/lib/python3.3/dist-packages/django/db/models/sql/compiler.py", line 711, in results_iter
for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python3.3/dist-packages/django/db/models/sql/compiler.py", line 777, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python3.3/dist-packages/django/db/backends/util.py", line 46, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.3/dist-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python3.3/dist-packages/django/utils/six.py", line 328, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.3/dist-packages/django/db/backends/util.py", line 46, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.3/dist-packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)
File "/usr/local/lib/python3.3/dist-packages/MySQL_python-1.2.3-py3.3-linux-x86_64.egg/MySQLdb/cursors.py", line 184, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python3.3/dist-packages/MySQL_python-1.2.3-py3.3-linux-x86_64.egg/MySQLdb/connections.py", line 37, in defaulterrorhandler
raise errorvalue
File "/usr/local/lib/python3.3/dist-packages/MySQL_python-1.2.3-py3.3-linux-x86_64.egg/MySQLdb/cursors.py", line 171, in execute
r = self._query(query)
File "/usr/local/lib/python3.3/dist-packages/MySQL_python-1.2.3-py3.3-linux-x86_64.egg/MySQLdb/cursors.py", line 330, in _query
rowcount = self._do_query(q)
File "/usr/local/lib/python3.3/dist-packages/MySQL_python-1.2.3-py3.3-linux-x86_64.egg/MySQLdb/cursors.py", line 294, in _do_query
db.query(q)
django.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s AND `django_content_type`.`app_label` = %s )' at line 1")
I have successfully installed python3 , mysql driver. Using ubuntu.
Here is my setings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME' : 'blog',
'USER' : 'root',
'PASSWORD' : 'hellyeah',
'HOST' : '',
'PORT' : ''
}
}
It would be awesome if somebody teach me whats wrong..
This is because you are using Python 3 with django. There is no driver currently available for it. Since you're starting with django and Python, why not use Sqlite, it has a good Python3 driver, and will suffice for your learning experience.
You may also try using Postgres, but that has a lot more setting up to do than Sqlite.