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.
Related
I just deleted my localhost database due to export my production website database and then import it to my lcoal db
I used this command to dump db:
./manage.py dumpdata --exclude contenttypes --exclude auth.permission
--exclude sessions --indent 2 > dump.json
and then on my localhost:
./manage.py loaddata dump.json
but I get error:
Traceback (most recent call last):
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 74, in execute
return self.cursor.execute(query, args)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 209, in execute
res = self._query(query)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 315, in _query
db.query(q)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 239, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.IntegrityError: (1062, "Duplicate entry '1' for key 'user_id'")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "./manage.py", line 21, in <module>
main()
File "./manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/core/management/base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 72, in handle
self.loaddata(fixture_labels)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 114, in loaddata
self.load_label(fixture_label)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 181, in load_label
obj.save(using=self.using)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/core/serializers/base.py", line 223, in save
models.Model.save_base(self.object, using=using, raw=True, **kwargs)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/db/models/base.py", line 782, in save_base
updated = self._save_table(
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/db/models/base.py", line 887, in _save_table
results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/db/models/base.py", line 924, in _do_insert
return manager._insert(
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/db/models/query.py", line 1204, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1392, in execute_sql
cursor.execute(sql, params)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 74, in execute
return self.cursor.execute(query, args)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 209, in execute
res = self._query(query)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 315, in _query
db.query(q)
File "/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 239, in query
_mysql.connection.query(self, query)
django.db.utils.IntegrityError: Problem installing fixture '/home/mehdi/python/projects/FollowBotWebsite/v1.2.2/dump.json': Could not load users.Profile(pk=1): (1062, "Duplicate entry '1' for key 'user_id'")
I searched a lot but all soloutions were about permissions or auth, not my own models.
I used signals to make a profile for each user on creation,
solved this problem with addign not raw to my signals:
#receiver(post_save, sender=User)
def create_profile(sender, instance, created, raw=False, **kwargs):
if created and not raw:
Profile.objects.create(user=instance)
print('Profile Created')
I'm sorry, I don't think the title of my question is comprehensible as I'm absolutely a noob trying to understand django after LPTHW. Anyway, I'm following a tutorial in setting up Django to use MariaDB. But unfortunately when I run python manage.py migrate I get humongous block of error message. Here's the block:
System check identified some issues:
WARNINGS:
?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default'
HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/2.1/ref/databases/#mysql-sql-mode
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial...Traceback (most recent call last):
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 83, in _execute
return self.cursor.execute(sql)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 71, in execute
return self.cursor.execute(query, args)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 412, in _query
rowcount = self._do_query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 375, in _do_query
db.query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 276, in query
_mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1050, "Table 'django_content_type' already exists")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 203, in handle
fake_initial=fake_initial,
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/migrations/executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/migrations/migration.py", line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/migrations/operations/models.py", line 91, in database_forwards
schema_editor.create_model(model)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 312, in create_model
self.execute(sql, params or None)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 133, in execute
cursor.execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 83, in _execute
return self.cursor.execute(sql)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 71, in execute
return self.cursor.execute(query, args)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 412, in _query
rowcount = self._do_query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 375, in _do_query
db.query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 276, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1050, "Table 'django_content_type' already exists")
Expecting another command to work after that error, I ran
python manage.py createsuperuser which returned me another block of error:
You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
Traceback (most recent call last):
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 71, in execute
return self.cursor.execute(query, args)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 412, in _query
rowcount = self._do_query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 375, in _do_query
db.query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 276, in query
_mysql.connection.query(self, query)
_mysql_exceptions.ProgrammingError: (1146, "Table 'myproject.auth_user' doesn't exist")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 59, in execute
return super().execute(*args, **options)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 93, in handle
default_username = get_default_username()
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/contrib/auth/management/__init__.py", line 136, in get_default_username
auth_app.User._default_manager.get(username=default_username)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/models/query.py", line 393, in get
num = len(clone)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/models/query.py", line 250, in __len__
self._fetch_all()
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/models/query.py", line 1183, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/models/query.py", line 54, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1061, in execute_sql
cursor.execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 71, in execute
return self.cursor.execute(query, args)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 412, in _query
rowcount = self._do_query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/cursors.py", line 375, in _do_query
db.query(q)
File "/home/noob/Documents/projects/python/django/myproject/myprojectenv/lib/python3.5/site-packages/MySQLdb/connections.py", line 276, in query
_mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1146, "Table 'myproject.auth_user' doesn't exist")
Could you help me solve this?
I keep getting an error with my redshift database, I can't seem to run a ./manage.py inspectdb command on the database.
I did a select * from pg_user, and verified my user was a superuser.
Still not sure why this problem exists, https://forums.aws.amazon.com/thread.jspa?threadID=133514 this is an old link to the problem.
Error:
django.db.utils.ProgrammingError: must be superuser to examine "max_index_keys"
CONTEXT: SQL function "_pg_keypositions" statement 1
The error log:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/webapps/hello_django/local/lib/python2.7/site-packages/django/core/mana gement/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/webapps/hello_django/local/lib/python2.7/site-packages/django/core/mana gement/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/webapps/hello_django/local/lib/python2.7/site-packages/django/core/mana gement/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "/webapps/hello_django/local/lib/python2.7/site-packages/django/core/mana gement/base.py", line 444, in execute
output = self.handle(*args, **options)
File "/webapps/hello_django/local/lib/python2.7/site-packages/django/core/mana gement/commands/inspectdb.py", line 25, in handle
for line in self.handle_inspection(options):
File "/webapps/hello_django/local/lib/python2.7/site-packages/django/core/mana gement/commands/inspectdb.py", line 72, in handle_inspection
constraints = connection.introspection.get_constraints(cursor, table_name)
File "/webapps/hello_django/local/lib/python2.7/site-packages/django/db/backen ds/postgresql_psycopg2/introspection.py", line 187, in get_constraints
""", ["public", table_name])
File "/webapps/hello_django/local/lib/python2.7/site-packages/django/db/backen ds/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/webapps/hello_django/local/lib/python2.7/site-packages/django/db/backen ds/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/webapps/hello_django/local/lib/python2.7/site-packages/django/db/utils. py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/webapps/hello_django/local/lib/python2.7/site-packages/django/db/backen ds/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: must be superuser to examine "max_index_keys"
CONTEXT: SQL function "_pg_keypositions" statement 1
I have a new server just installed. Everything seems to be fine but when i run:
python manage.py syncdb
it generates follow error:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/usr/lib/python2.6/site-packages/django/core/management/commands/syncdb.py", line 109, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "/usr/lib/python2.6/site-packages/django/core/management/sql.py", line 190, in emit_post_sync_signal
interactive=interactive, db=db)
File "/usr/lib/python2.6/site-packages/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "/usr/lib/python2.6/site-packages/django/contrib/auth/management/__init__.py", line 51, in create_permissions
content_type=ctype
File "/usr/lib/python2.6/site-packages/django/db/models/manager.py", line 138, in create
return self.get_query_set().create(**kwargs)
File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 360, in create
obj.save(force_insert=True, using=self.db)
File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 460, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 553, in save_base
result = manager._insert(values, return_id=update_pk, using=using)
File "/usr/lib/python2.6/site-packages/django/db/models/manager.py", line 195, in _insert
return insert_query(self.model, values, **kwargs)
File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 1436, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 791, in execute_sql
cursor = super(SQLInsertCompiler, self).execute_sql(None)
File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
cursor.execute(sql, params)
File "/usr/lib/python2.6/site-packages/django/db/backends/util.py", line 34, in execute
return self.cursor.execute(sql, params)
File "/usr/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 86, in execute
return self.cursor.execute(query, args)
File "/usr/lib/python2.6/site-packages/MySQLdb/cursors.py", line 175, in execute
if not self._defer_warnings: self._warning_check()
File "/usr/lib/python2.6/site-packages/MySQLdb/cursors.py", line 89, in _warning_check
warn(w[-1], self.Warning, 3)
_mysql_exceptions.Warning: Incorrect string value: '\xE6\x99\xAF\xE9\xBB\x9E...' for column 'name' at row 1
All the tables and fields, in fact, created automatically without observable problem. I just wanna get rid of this error becoz the same thing does not happen in my old server with exactly the same project running on it.
So I am answering it here so that other people can have answer of same problem:
As said by Bill Kary:
He have solved this himself. Change all the collation of ALL tables AND fields to utf (utf8_general_ci) stops the error beautifully.
look the end line:ProgrammingError: (1146, "Table 'test.sphinx_test_file' doesn't exist")
Traceback (most recent call last):
File "D:\Python25\Lib\site-packages\django\core\servers\basehttp.py", line 280, in run
self.finish_response()
File "D:\Python25\Lib\site-packages\django\core\servers\basehttp.py", line 319, in finish_response
for data in self.result:
File "D:\Python25\Lib\site-packages\django\http\__init__.py", line 374, in __iter__
self._iterator = iter(self._container)
File "D:\zjm_code\sphinx_test\djangosphinx\models.py", line 240, in __iter__
return iter(self._get_data())
File "D:\zjm_code\sphinx_test\djangosphinx\models.py", line 404, in _get_data
self._result_cache = list(self._get_results())
File "D:\zjm_code\sphinx_test\djangosphinx\models.py", line 570, in _get_results
queryset = dict([(', '.join([unicode(getattr(o, p.attname)) for p in pks]), o) for o in queryset])
File "D:\Python25\Lib\site-packages\django\db\models\query.py", line 106, in _result_iter
self._fill_cache()
File "D:\Python25\Lib\site-packages\django\db\models\query.py", line 692, in _fill_cache
self._result_cache.append(self._iter.next())
File "D:\Python25\Lib\site-packages\django\db\models\query.py", line 238, in iterator
for row in self.query.results_iter():
File "D:\Python25\Lib\site-packages\django\db\models\sql\query.py", line 287, in results_iter
for rows in self.execute_sql(MULTI):
File "D:\Python25\Lib\site-packages\django\db\models\sql\query.py", line 2369, in execute_sql
cursor.execute(sql, params)
File "D:\Python25\Lib\site-packages\django\db\backends\util.py", line 19, in execute
return self.cursor.execute(sql, params)
File "D:\Python25\Lib\site-packages\django\db\backends\mysql\base.py", line 84, in execute
return self.cursor.execute(query, args)
File "D:\Python25\Lib\site-packages\MySQLdb\cursors.py", line 163, in execute
self.errorhandler(self, exc, value)
File "D:\Python25\Lib\site-packages\MySQLdb\connections.py", line 35, in defaulterrorhandler
raise errorclass, errorvalue
ProgrammingError: (1146, "Table 'test.sphinx_test_file' doesn't exist")
Did you run syncdb after adding the app (I'm guessing the app is named sphinx) to your settings.py?