Migration fails trying to add a constraint to db - python

I'm trying to use django models to create constraints on my database, what am I doing wrong here?
I'm using django 2.2.2 on Python 3.7.3
Here is my model class:
class Client(models.Model):
class Meta:
db_table = 'Client'
constraints = [
models.CheckConstraint(check=models.Q(cnpj__regex='\\d{14}'), name='valid_cnpj'),
]
id = HashidAutoField(primary_key=True)
trade_name = models.CharField(max_length=200)
cnpj = models.CharField(max_length=14)
business_name = models.CharField(max_length=200, null=True)
Error message: AttributeError: 'str' object has no attribute 'connector'
Full traceback:
Running migrations:
Applying global_models.0008_auto_20190809_1747...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 "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\lib\site-packages\django\core\management\commands\migrate.py", line 234, in handle
fake_initial=fake_initial,
File "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\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 "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\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 "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\lib\site-packages\django\db\migrations\executor.py", line 245, in apply_migration
state = migration.apply(state, schema_editor)
File "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\lib\site-packages\django\db\migrations\migration.py", line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\lib\site-packages\django\db\migrations\operations\models.py", line 827, in database_forwards
schema_editor.add_constraint(model, self.constraint)
File "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\lib\site-packages\django\db\backends\base\schema.py", line 343, in add_constraint
sql = constraint.create_sql(model, self)
File "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\lib\site-packages\django\db\models\constraints.py", line 47, in create_sql
check = self._get_check_sql(model, schema_editor)
File "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\lib\site-packages\django\db\models\constraints.py", line 37, in _get_check_sql
where = query.build_where(self.check)
File "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\lib\site-packages\django\db\models\sql\query.py", line 1296, in build_where
return self._add_q(q_object, used_aliases=set(), allow_joins=False, simple_col=True)[0]
File "C:\Users\Celere.LAPTOP-FLPOSE6C\PycharmProjects\api_django\venv\lib\site-packages\django\db\models\sql\query.py", line 1302, in _add_q
connector = q_object.connector

Related

Why does using a django BooleanField in models.py cause a TypeError?

I'm creating a model for a todo list program. Here is my models.py file:
from django.db import models
from django.contrib.auth.models import User
class Todo(models.Model):
content = models.CharField(max_length=250)
completed = models.BooleanField(default=False)
author = models.ForeignKey(User, on_delete=models.CASCADE)
def __str__(self):
return self.content
When I try to run python manage.py migrate after I make migrations, it gives me this error:
TypeError: memoryview: a bytes-like object is required, not 'bool'
I'm not sure how to fix this, but I'm guessing it has something to do with the Boolean Field. Thanks in advance!
EDIT:
Here's the entire error that I got:
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/Users/thuitema/anaconda3/lib/python3.7/site-
packages/django/core/management/__init__.py", line 401, in
execute_from_command_line
utility.execute()
File "/Users/thuitema/anaconda3/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/thuitema/anaconda3/lib/python3.7/site-packages/django/core/management/base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/thuitema/anaconda3/lib/python3.7/site-packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/Users/thuitema/anaconda3/lib/python3.7/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/Users/thuitema/anaconda3/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 233, in handle
fake_initial=fake_initial,
File "/Users/thuitema/anaconda3/lib/python3.7/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 "/Users/thuitema/anaconda3/lib/python3.7/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 "/Users/thuitema/anaconda3/lib/python3.7/site-packages/django/db/migrations/executor.py", line 245, in apply_migration
state = migration.apply(state, schema_editor)
File "/Users/thuitema/anaconda3/lib/python3.7/site-packages/django/db/migrations/migration.py", line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/Users/thuitema/anaconda3/lib/python3.7/site-packages/django/db/migrations/operations/fields.py", line 112, in database_forwards
field,
File "/Users/thuitema/anaconda3/lib/python3.7/site-packages/django/db/backends/sqlite3/schema.py", line 328, in add_field
self._remake_table(model, create_field=field)
File "/Users/thuitema/anaconda3/lib/python3.7/site-packages/django/db/backends/sqlite3/schema.py", line 189, in _remake_table
self.effective_default(create_field)
File "/Users/thuitema/anaconda3/lib/python3.7/site-packages/django/db/backends/base/schema.py", line 303, in effective_default
return field.get_db_prep_save(self._effective_default(field), self.connection)
File "/Users/thuitema/anaconda3/lib/python3.7/site-packages/django/db/models/fields/__init__.py", line 821, in get_db_prep_save
return self.get_db_prep_value(value, connection=connection, prepared=False)
File "/Users/thuitema/anaconda3/lib/python3.7/site-packages/django/db/models/fields/__init__.py", line 2262, in get_db_prep_value
return connection.Database.Binary(value)
TypeError: memoryview: a bytes-like object is required, not 'bool'
File "/Users/xxxxx/anaconda3/lib/python3.7/site-packages/django/db/models/fields/__init__.py", line 2262, in get_db_prep_value
return connection.Database.Binary(value)
TypeError: memoryview: a bytes-like object is required, not 'bool'
The last two lines of your error log suggest that the model was originally built with the models.BinaryField() field type which would throw this type error with default=False. Rebuilding and running the migration with the models.BooleanField(default=False) line you already have above should solve it:
python manage.py makemigrations
python manage.py migrate

Django manage.py test: “database backend does not accept 0 as a value for AutoField” (mysql)

I am trying to run the Django tests file using:
python3.6 manage.py test
I use: MySQL 5.5.62, Python 3.6, Django 2.0.0
It starts installing a test DB and fails with the error:
ValueError: The database backend does not accept 0 as a value for AutoField.
I searched for this error but all the topics I found were related to migrations, such as this one. I have no problem with migrations, they run smoothly.
Traceback:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/test.py", line 26, in run_from_argv
super().run_from_argv(argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/test.py", line 59, in handle
failures = test_runner.run_tests(test_labels)
File "/usr/local/lib/python3.6/site-packages/django/test/runner.py", line 601, in run_tests
old_config = self.setup_databases()
File "/usr/local/lib/python3.6/site-packages/django/test/runner.py", line 548, in setup_databases
self.parallel, **kwargs
File "/usr/local/lib/python3.6/site-packages/django/test/utils.py", line 176, in setup_databases
serialize=connection.settings_dict.get('TEST', {}).get('SERIALIZE', True),
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/creation.py", line 68, in create_test_db
run_syncdb=True,
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 141, in call_command
return command.execute(*args, **defaults)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 200, in handle
fake_initial=fake_initial,
File "/usr/local/lib/python3.6/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 "/usr/local/lib/python3.6/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 "/usr/local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/usr/local/lib/python3.6/site-packages/django/db/migrations/migration.py", line 122, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/usr/local/lib/python3.6/site-packages/django/db/migrations/operations/fields.py", line 216, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 509, in alter_field
old_db_params, new_db_params, strict)
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 613, in _alter_field
old_default = self.effective_default(old_field)
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 224, in effective_default
default = field.get_db_prep_save(default, self.connection)
File "/usr/local/lib/python3.6/site-packages/django/db/models/fields/related.py", line 936, in get_db_prep_save
return self.target_field.get_db_prep_save(value, connection=connection)
File "/usr/local/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 767, in get_db_prep_save
return self.get_db_prep_value(value, connection=connection, prepared=False)
File "/usr/local/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 940, in get_db_prep_value
value = connection.ops.validate_autopk_value(value)
File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/operations.py", line 163, in validate_autopk_value
raise ValueError('The database backend does not accept 0 as a '
ValueError: The database backend does not accept 0 as a value for AutoField.
How can I fix this error and run the tests?
OK it seems it was indeed migrations as #Willem Van Onsem suggested. I ended up deleting the migrations and that cleared the issue.
It might be worth pointing out the the mess was caused by switching from Django models to Django MTPP models and using 0 as a default value for the newly added MTPP fields to avoid another issue in that process.

Django: ValueError during migration (how to fix???)

I have 2 classes. Student and parent. The parent class links to the student class via a models.ForeignKey(Student, on_delete=models.CASCADE)
When running makemigrations django asked whether I wanted to input because there was no default. So I input "defult". Turns out it wanted a string and now whenever I run migrate it gives me the ValueError which I have no clue how to fix or what to do. I've tried deleting migrations folder and removing both models but still nope.
C:\Users\Egor\Desktop\mysite>python manage.py makemigrations
Migrations for 'main':
main\migrations\0028_auto_20190129_2010.py
- Alter field student_joined on student
C:\Users\Egor\Desktop\mysite>python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, main, sessions
Running migrations:
Applying main.0007_auto_20190129_1732...Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-
packages\django\core\management\__init__.py", line 381, in
execute_from_command_line
utility.execute()
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 353, in execute
output = self.handle(*args, **options)
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\migrate.py", line 203, in handle
fake_initial=fake_initial,
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\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 "C:\Users\Egor\AppData\Local\Programs\Python\Python37\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 "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\migrations\executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\migrations\migration.py", line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\migrations\operations\fields.py", line 84, in database_forwards
field,
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\sqlite3\schema.py", line 309, in add_field
self._remake_table(model, create_field=field)
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\sqlite3\schema.py", line 181, in _remake_table
self.effective_default(create_field)
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\base\schema.py", line 239, in effective_default
return field.get_db_prep_save(default, self.connection)
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\fields\related.py", line 937, in get_db_prep_save
return self.target_field.get_db_prep_save(value, connection=connection)
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\fields\__init__.py", line 790, in get_db_prep_save
return self.get_db_prep_value(value, connection=connection, prepared=False)
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\fields\__init__.py", line 956, in get_db_prep_value
value = self.get_prep_value(value)
File "C:\Users\Egor\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\fields\__init__.py", line 965, in get_prep_value
return int(value)
ValueError: invalid literal for int() with base 10: 'Defult'
models code:
class Student(models.Model):
student_name = models.CharField(max_length=200)
student_gender = models.CharField(max_length=1)
student_parent_email = models.EmailField()
student_joined = models.DateTimeField('date joined', default=datetime.now())
def __str__(self):
return self.student_name
class Parent(models.Model):
mother = models.CharField(max_length=200)
father = models.CharField(max_length=200)
stu = models.ForeignKey(Student, on_delete=models.CASCADE)
I have no clue what to do now. Please help as to how to get rid of this value error.
Thank you

ValueError: invalid literal for int() with base 10: 'SOME STRING'

I have a problem when I write in cmd this "python manage.py migrate"
I found this error
{ValueError: invalid literal for int() with base 10: 'SOME STRING'}
this is my code
class GameScore(models.Model):
FirstTeam = models.CharField(max_length=256, null=True)
SecondTeam = models.CharField(max_length=256, null=True)
first_team_score = models.IntegerField(default=0)
second_team_score = models.IntegerField(default=0)
game_date = models.DateTimeField(auto_now=True)
def __str__(self):
return '{} {} - {} {}'.format(self.FirstTeam, self.first_team_score, self.SecondTeam, self.second_team_score)
this is full Traceback
https://i.stack.imgur.com/RM284.png
Apply all migrations: admin, auth, contenttypes, sessions, team
Running migrations:
Applying team.0007_auto_20180504_0343...Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
utility.execute()
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\core\management\__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\core\management\base.py", line 330, in execute
output = self.handle(*args, **options)
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\core\management\commands\migrate.py", line 204, in handle
fake_initial=fake_initial,
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\db\migrations\executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\db\migrations\executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\db\migrations\executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\db\migrations\migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\db\migrations\operations\fields.py", line 88, in database_forwards
field,
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\db\backends\sqlite3\schema.py", line 238, in add_field
self._remake_table(model, create_field=field)
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\db\backends\sqlite3\schema.py", line 113, in _remake_table
self.effective_default(create_field)
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\db\backends\base\schema.py", line 229, in effective_default
default = field.get_db_prep_save(default, self.connection)
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\db\models\fields\related.py", line 963, in get_db_prep_save
return self.target_field.get_db_prep_save(value, connection=connection)
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\db\models\fields\__init__.py", line 770, in get_db_prep_save
prepared=False)
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\db\models\fields\__init__.py", line 958, in get_db_prep_value
value = self.get_prep_value(value)
File "C:\Users\haytham\Desktop\teammanager_env\lib\site-packages\django\db\models\fields\__init__.py", line 966, in get_prep_value
return int(value)
ValueError: invalid literal for int() with base 10: 'SOME STRING'
I don't know how to solve this problem
Think of the () as a list. You need numbers to tell which value to pull.
return '{0} {1} - {2} {3}'.format(self.FirstTeam, self.first_team_score, self.SecondTeam, self.second_team_score)
If you are using Python 3.6 you could use f’{self.whatever}’.

django specifc stack trace when running migrations in django.

here are the database tables I have made
from __future__ import unicode_literals
from django.db import models
class Venue(models.Model):
name = models.CharField(max_length=100)
address = models.ForeignKey('Address', blank=True, related_name='venue', on_delete=models.CASCADE)
phone = models.BigIntegerField(blank=True)
class Address(models.Model):
street1 = models.CharField(max_length=100)
street2 = models.CharField(max_length =100)
city = models.CharField(max_length = 100)
state = models.CharField(max_length = 2, blank =True)
zipcode = models.PositiveSmallIntegerField()
country = models.CharField(max_length = 100, blank = True)
and here is the stacktrace it seems to be django specifc. Anyone see this before?
Apply all migrations: admin, auth, contenttypes, sessions, venue
Running migrations:
Applying venue.0002_auto_20161220_2343...Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/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 "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 84, in database_forwards
field,
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/db/backends/postgresql/schema.py", line 21, in add_field
super(DatabaseSchemaEditor, self).add_field(model, field)
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 395, in add_field
definition, params = self.column_sql(model, field, include_default=True)
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 147, in column_sql
default_value = self.effective_default(field)
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 221, in effective_default
default = field.get_db_prep_save(default, self.connection)
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 909, in get_db_prep_save
return self.target_field.get_db_prep_save(value, connection=connection)
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 755, in get_db_prep_save
prepared=False)
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 938, in get_db_prep_value
value = self.get_prep_value(value)
File "/home/rickus/211hospitality/com.suitsandtables/venv/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 946, in get_prep_value
return int(value)
TypeError: int() argument must be a string or a number, not 'dict'
I am using a postgress backend. The looks of my code and migrate, it all makes no sense. Rather frustrating.

Categories

Resources