python manage.py runserver 127.0.0.1:80 - python-2.7

Traceback (most recent call last):
File "manage.py", line 28, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 231, in execute
self.validate()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 266, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 30, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 158, in get_app_errors
self._populate()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 64, in _populate
self.load_app(app_name, True)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 88, in load_app
models = import_module('.models', app_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/cartridge/shop/models.py", line 411, in <module>
class Order(models.Model):
File "/usr/local/lib/python2.7/dist-packages/cartridge/shop/models.py", line 422, in Order
billing_detail_country = ForeignKey(Category, verbose_name = _("State/Region"), related_name='order', limit_choices_to={ "parent":Category.objects.get(slug='regions') }, blank=True, null=True)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 131, in get
return self.get_query_set().get(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 361, in get
num = len(clone)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 85, in __len__
self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 291, in iterator
for row in compiler.results_iter():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 763, in results_iter
for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 818, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 40, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py", line 344, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: no such table: shop_category
Hello.
python manage.py runserver 127.0.0.1:80 not running on server.
In MySQL table shop_category present. In settings.py name DB, login and password configured.
syncdb not solved my problem.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',

Related

I connected my Django app to MLabs, what do I do now to be able to migrate my database structure to it?

I successfully connected my Django app on my computer to Mlab using Djongo and the homepage on my localhost:8000 server seems to be displaying correctly. However, when I run 'py manage.py migrate', it gives a long list of errors in the terminal and I am not sure how to properly connect to the Mlabs database and populate it with data from the terminal of my Django app in my local computer. How do I migrate the database information onto my Mlab database? I'm not sure what the error is. I'm a little new to Django and MongoDB.
This is a part of the error I see:
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\cursor.py", line 51, in execute
self.result = Query(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 783, in __init__
self._query = self.parse()
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 868, in parse
raise exe from e
djongo.exceptions.SQLDecodeError:
Keyword: None
Sub SQL: None
FAILED SQL: INSERT INTO "django_migrations" ("app", "name", "applied") VALUES (%(0)s, %(1)s, %(2)s)
Params: ['contenttypes', '0001_initial', datetime.datetime(2020, 7, 29, 21, 36, 46, 283726)]
Version: 1.3.3
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\cursor.py", line 59, in execute
raise db_exe from e
djongo.database.DatabaseError
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 "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\migrate.py", line 231, in handle
post_migrate_state = executor.migrate(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\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 "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\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 "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 246, in apply_migration
self.record_migration(migration)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 261, in record_migration
self.recorder.record_applied(migration.app_label, migration.name)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\recorder.py", line 86, in record_applied
self.migration_qs.create(app=app, name=name)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 433, in create
obj.save(force_insert=True, using=self.db)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
745, in save
self.save_base(using=using, force_insert=force_insert,
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
782, in save_base
updated = self._save_table(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\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 "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
924, in _do_insert
return manager._insert(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 1204, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\sql\compiler.py", line 1391, in execute_sql
PS D:\Business\Daydoa\v6-Django_with_MongoDB3\djongo_project> py manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial...This version of djongo does not support "schema validation using CONSTRAINT" fully. Visit https://www.patreon.com/nesdis
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\mongo_client.py", line 1384, in _retry_with_session
return func(session, sock_info, retryable)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\collection.py", line 2873, in _find_and_modify
out = self._command(sock_info, cmd,
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\collection.py", line 235, in _command
return sock_info.command(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\pool.py", line 603, in command
return command(self.sock, dbname, spec, slave_ok,
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\network.py", line 165, in command
helpers._check_command_response(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\helpers.py", line 159, in _check_command_response
raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: Transaction numbers are only allowed on storage engines that support document-level locking
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 856, in parse
return handler(self, statement)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 928, in _insert
query.execute()
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 374, in execute
auto = self.db['__schema__'].find_one_and_update(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\collection.py", line 3134, in find_one_and_update
return self.__find_and_modify(filter, projection,
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\collection.py", line 2884, in __find_and_modify
return self.__database.client._retryable_write(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\mongo_client.py", line 1491, in _retryable_write
return self._retry_with_session(retryable, func, s, None)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\mongo_client.py", line 1425, in _retry_with_session
raise OperationFailure(errmsg, exc.code, exc.details)
pymongo.errors.OperationFailure: This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\cursor.py", line 51, in execute
self.result = Query(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 783, in __init__
self._query = self.parse()
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\sql2mongo\query.py", line 868, in parse
raise exe from e
djongo.exceptions.SQLDecodeError:
Keyword: None
Sub SQL: None
FAILED SQL: INSERT INTO "django_migrations" ("app", "name", "applied") VALUES (%(0)s, %(1)s, %(2)s)
Params: ['contenttypes', '0001_initial', datetime.datetime(2020, 7, 29, 21, 37, 1, 197586)]
Version: 1.3.3
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\cursor.py", line 59, in execute
raise db_exe from e
djongo.database.DatabaseError
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 "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\migrate.py", line 231, in handle
post_migrate_state = executor.migrate(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\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 "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\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 "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 246, in apply_migration
self.record_migration(migration)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 261, in record_migration
self.recorder.record_applied(migration.app_label, migration.name)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\recorder.py", line 86, in record_applied
self.migration_qs.create(app=app, name=name)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 433, in create
obj.save(force_insert=True, using=self.db)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
745, in save
self.save_base(using=using, force_insert=force_insert,
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
782, in save_base
updated = self._save_table(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\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 "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\base.py", line
924, in _do_insert
return manager._insert(
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 1204, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\sql\compiler.py", line 1391, in execute_sql
cursor.execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 100, in execute
return super().execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "D:\Users\simon\AppData\Local\Programs\Python\Python38\lib\site-packages\djongo\cursor.py", line 59, in execute
raise db_exe from e
django.db.utils.DatabaseError

Makemigrations gives ValueError: too many values to unpack

I have a working project and I would like to add one new field to one of the models.
I have added the new field and ran the makemigrations command and then I got ValueError: too many values to unpack
This is the model:
class Line(models.Model):
name = models.CharField(max_length=250, null=False, blank=False, unique=True)
label_name = models.CharField(max_length=250, null=True, blank=True, unique=True)
and I wanted to add this field:
link = models.CharField(max_length=200,null=True,blank=True, unique=True)
Then I ran makemigrations command, and got this exception exception:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2017.3.3\helpers\pycharm\django_manage.py", line 52, in <module>
run_command()
File "C:\Program Files\JetBrains\PyCharm 2017.3.3\helpers\pycharm\django_manage.py", line 46, in run_command
run_module(manage_file, None, '__main__', True)
File "C:\Python27\lib\runpy.py", line 176, in run_module
fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 82, in _run_module_code
mod_name, mod_fname, mod_loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "F:\cellular_resolution_map_of_larval_zebrafish\manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 350, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 399, in execute
output = self.handle(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\makemigrations.py", line 105, in handle
loader.project_state(),
File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", line 338, in project_state
return self.graph.make_state(nodes=nodes, at_end=at_end, real_apps=list(self.unmigrated_apps))
File "C:\Python27\lib\site-packages\django\db\migrations\graph.py", line 280, in make_state
project_state = self.nodes[node].mutate_state(project_state, preserve=False)
File "C:\Python27\lib\site-packages\django\db\migrations\migration.py", line 88, in mutate_state
operation.state_forwards(self.app_label, new_state)
File "C:\Python27\lib\site-packages\django\db\migrations\operations\fields.py", line 51, in state_forwards
state.reload_model(app_label, self.model_name_lower)
File "C:\Python27\lib\site-packages\django\db\migrations\state.py", line 148, in reload_model
self.apps.render_multiple(states_to_be_rendered)
File "C:\Python27\lib\site-packages\django\db\migrations\state.py", line 296, in render_multiple
model.render(self)
File "C:\Python27\lib\site-packages\django\db\migrations\state.py", line 585, in render
body,
File "C:\Python27\lib\site-packages\django\db\models\base.py", line 158, in __new__
new_class.add_to_class(obj_name, obj)
File "C:\Python27\lib\site-packages\django\db\models\base.py", line 299, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Python27\lib\site-packages\django\db\models\fields\related.py", line 702, in contribute_to_class
super(ForeignObject, self).contribute_to_class(cls, name, virtual_only=virtual_only)
File "C:\Python27\lib\site-packages\django\db\models\fields\related.py", line 308, in contribute_to_class
lazy_related_operation(resolve_related_class, cls, self.remote_field.model, field=self)
File "C:\Python27\lib\site-packages\django\db\models\fields\related.py", line 85, in lazy_related_operation
return apps.lazy_model_operation(partial(function, **kwargs), *model_keys)
File "C:\Python27\lib\site-packages\django\db\models\fields\related.py", line 83, in <genexpr>
model_keys = (make_model_tuple(m) for m in models)
File "C:\Python27\lib\site-packages\django\db\models\utils.py", line 13, in make_model_tuple
app_label, model_name = model.split(".")
ValueError: too many values to unpack
How can I solve it?
Thank you very much.

Django DB migration issue: non-existent attribute

After removing an attribute from a model (sqlite3):
class Course(models.Model):
Name = models.CharField(max_length=30,unique=True)
Active = models.BooleanField(default=True)
# rubric = models.ForeignKey(Rubric) #removed attribute
def __unicode__(self):
return u'%s' % (self.Name)
I get errors upon using migrate (makemigrations is fine):
django.db.utils.IntegrityError: NOT NULL constraint failed: gbook_course.rubric_id
This field doesn't exist anymore! I don't understand where this is failing, or where to fix it. Re-adding the attribute and using null=True, blank=True and changing the attribute to a CharField or other type also do not fix the problem.
Opening the DB from the sqlite command-line application and looking at the schema for the course table, I get the indication that there's no rubric field there:
CREATE TABLE "gbook_course" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "Active" bool NOT NULL, "Name" varchar(30) NOT NULL UNIQUE);
On a related note, I figured that maybe I had just borked the DB, so I also tried deleting it and the app's migrations (except for __init__.py), which should start the thing over from scratch, but I end up with an error both from the runserver and from the migrations:
django.db.utils.OperationalError: no such table: gbook_student
At this point, there's no DB in existence (totally deleted), so I'm really unsure as to where this error could possibly come from. A solution to either problem is fine - I can re-start with a blank DB, if needed.
migrate traceback:
ltjgates:gbsite jgates$ python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, gbook, sessions
Running migrations:
Rendering model states... DONE
Applying gbook.0011_course_rubric...Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 305, in run_from_argv
self.execute(*args, **cmd_options)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 356, in execute
output = self.handle(*args, **options)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 202, in handle
targets, plan, fake=fake, fake_initial=fake_initial
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/migrations/executor.py", line 97, in migrate
state = self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/migrations/executor.py", line 132, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/migrations/executor.py", line 237, in apply_migration
state = migration.apply(state, schema_editor)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 84, in database_forwards
field,
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/sqlite3/schema.py", line 231, in add_field
self._remake_table(model, create_fields=[field])
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/sqlite3/schema.py", line 199, in _remake_table
self.quote_name(model._meta.db_table),
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 112, in execute
cursor.execute(sql, params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 337, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.IntegrityError: NOT NULL constraint failed: gbook_course.rubric_id
Deleted DB traceback (makemigrations):
ltjgates:gbsite jgates$ python manage.py makemigrations
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 305, in run_from_argv
self.execute(*args, **cmd_options)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 353, in execute
self.check()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 385, in check
include_deployment_checks=include_deployment_checks,
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 372, in _run_checks
return checks.run_checks(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/checks/urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/checks/urls.py", line 24, in check_resolver
for pattern in resolver.url_patterns:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/urls/resolvers.py", line 310, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/urls/resolvers.py", line 303, in urlconf_module
return import_module(self.urlconf_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Volumes/ProfileHD/jgates/Desktop/Gbook/gbsite/gbsite/urls.py", line 21, in <module>
url(r'^gbook/', include('gbook.urls')),
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 50, in include
urlconf_module = import_module(urlconf_module)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Volumes/ProfileHD/jgates/Desktop/Gbook/gbsite/gbook/urls.py", line 2, in <module>
from . import views
File "/Volumes/ProfileHD/jgates/Desktop/Gbook/gbsite/gbook/views.py", line 12, in <module>
from gbook.forms import *
File "/Volumes/ProfileHD/jgates/Desktop/Gbook/gbsite/gbook/forms.py", line 38, in <module>
class StudentChooseForm(forms.ModelForm):
File "/Volumes/ProfileHD/jgates/Desktop/Gbook/gbsite/gbook/forms.py", line 39, in StudentChooseForm
class Meta:
File "/Volumes/ProfileHD/jgates/Desktop/Gbook/gbsite/gbook/forms.py", line 45, in Meta
'Email': CheckboxSelectMultiple(choices=( (x.id, x.FirstName+" "+x.LastName) for x in CHOICES )),
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", line 256, in __iter__
self._fetch_all()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", line 1085, in _fetch_all
self._result_cache = list(self.iterator())
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", line 54, in __iter__
results = compiler.execute_sql()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 835, in execute_sql
cursor.execute(sql, params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 337, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: gbook_student
Still not sure of the exact cause, but this worked (in the SQLite command line tool):
sqlite> select * from gbook_course;
1|1|Honors Physics
2|1|Physics
3|1|AP Physics
sqlite> delete from gbook_course;
Now the schema shows up with:
CREATE TABLE "gbook_course" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "Name" varchar(30) NOT NULL UNIQUE, "Active" bool NOT NULL, "rubric_id" integer NULL REFERENCES "gbook_rubric" ("id"));
CREATE INDEX "gbook_course_8980b7ae" ON "gbook_course" ("rubric_id");

Django-notifications won't sync

I'm trying to set up django-notifications in my app. I'm following the instructions to install it, which are pretty straight-forward: https://github.com/brantyoung/django-notifications#installation
When I run manage.py migrate notifications I get:
django.db.utils.ProgrammingError: (1146, "Table '{{database}}.notifications_notification' doesn't exist")
I'm at a loss.
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/management/commands/migrate.py", line 111, in handle
ignore_ghosts = ignore_ghosts,
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/migration/__init__.py", line 220, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/migration/migrators.py", line 230, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/migration/migrators.py", line 305, in migrate_many
result = self.migrate(migration, database)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/migration/migrators.py", line 134, in migrate
result = self.run(migration, database)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/migration/migrators.py", line 115, in run
return self.run_migration(migration, database)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/migration/migrators.py", line 85, in run_migration
migration_function()
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/migration/migrators.py", line 61, in <lambda>
return (lambda: direction(orm))
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/notifications/migrations/0002_auto__add_field_notification_data.py", line 14, in forwards
keep_default=False)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/db/generic.py", line 47, in _cache_clear
return func(self, table, *args, **opts)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/db/generic.py", line 418, in add_column
self.execute(sql)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/db/generic.py", line 282, in execute
cursor.execute(sql, params)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/db/backends/util.py", line 69, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/MySQLdb/cursors.py", line 201, in execute
self.errorhandler(self, exc, value)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.ProgrammingError: (1146, "Table 'ownershipdb.notifications_notification' doesn't exist")
You forget to run syncdb before migrating data. The table doesn't exists because it's syncdb that created it, not the migration.
Reference: http://south.readthedocs.org/en/latest/tutorial/part1.html
(If this fails complaining that south_migrationhistory does not exist, you forgot to run syncdb after you installed South.)

moving django site to another server

I want to move my django site to another machine.
(I want to start with empty DB)
I thought i'll be done with the following steps.
copy all files
setup all tools(django,python,..etc)
run syncdb
When I run manage.py syncdb, it complains some table(such as django_content_type) doesn't exist.
I looked at the DB, indeed there are no tables in the DB.
I tried recreate project(startproject) or recreate app(startapp).
(But they fail because the project or app name is already taken.)
What should I do?
The reason I can think of is mysql being upgraded to 5.5.27 (default to innodb)
$ python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/base.py", line 231, in execute
self.validate()
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/base.py", line 266, in validate
num_errors = get_validation_errors(s, app)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/validation.py", line 30, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/loading.py", line 158, in get_app_errors
self._populate()
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/loading.py", line 64, in _populate
self.load_app(app_name, True)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/loading.py", line 88, in load_app
models = import_module('.models', app_name)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/ubuntu/Documents/aLittleArtist/django/gallery/models.py", line 152, in <module>
ALBUM_IMAGE_TYPE = ContentType.objects.get(app_label="gallery", model="AlbumImage")
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/manager.py", line 131, in get
return self.get_query_set().get(*args, **kwargs)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/query.py", line 361, in get
num = len(clone)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/query.py", line 85, in __len__
self._result_cache = list(self.iterator())
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/query.py", line 291, in iterator
for row in compiler.results_iter():
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 763, in results_iter
for rows in self.execute_sql(MULTI):
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 818, in execute_sql
cursor.execute(sql, params)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/backends/util.py", line 40, in execute
return self.cursor.execute(sql, params)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 114, in execute
return self.cursor.execute(query, args)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.DatabaseError: (1146, "Table 'gallery_db.django_content_type' doesn't exist")
ALBUM_IMAGE_TYPE = ContentType.objects.get(app_label="gallery", model="AlbumImage")
This line was the culprit.
seems like the above line attempts to do DB query before any DB table is created.
I removed the line and relevant code and let syncdb run. and did migrate with south.