Hey guys I'm creating a basic app and it was running fine until I created a new table with my Models.py file that had a timestamp. My NewPost model already had the Timestamp and that was working fine. However, when I run migrate (makemigrations runs OK) I'm now getting a weird error in the console that the format is not correct and I'm unable to start my app.
I delete the timestamp fields, and I'm still getting the error! Can someone help me figure out what to do? Below is the error and my Models.py code. If you need any more code let me know. Thanks!
Models.py:
from django.contrib.auth.models import AbstractUser
from django.contrib.postgres.fields import ArrayField
from django.db import models
from datetime import datetime
class User(AbstractUser):
userRanking = models.IntegerField(default=0)
class NewPost(models.Model):
username = models.CharField(max_length=64)
body = models.CharField(max_length=64)
category = models.CharField(max_length=64, default="movies")
title = models.CharField(max_length=64, default="Hi", null="True")
rating = models.IntegerField(default=0)
timestamp = models.DateTimeField(auto_now_add=True, null=True)
class Vote(models.Model):
postID = models.IntegerField(default=0)
userID = models.IntegerField(default=0)
upVotes = models.IntegerField(default=0)
downVotes = models.IntegerField(default=0)
class Reply(models.Model):
postID = models.IntegerField(default=0)
username = models.CharField(max_length=64)
body = models.CharField(max_length=64, default="")
rating = models.IntegerField(default=0)
timestamp = models.DateTimeField(auto_now_add=True, null=True)
Error Message in Console:
C:\school\project4>python manage.py migrate network
Operations to perform:
Apply all migrations: network
Running migrations:
Applying contenttypes.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0001_initial... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying network.0001_initial... OK
Applying network.0002_auto_20201119_1427... OK
Applying network.0003_auto_20201119_1435... OK
Applying network.0004_auto_20201119_1438... OK
Applying network.0005_auto_20201119_1451... OK
Applying network.0006_auto_20201122_1812... OK
Applying network.0007_auto_20201124_1159... OK
Applying network.0008_auto_20201124_1557... OK
Applying network.0009_auto_20201207_1206... OK
Applying network.0010_newpost_category... OK
Applying network.0011_newpost_title... OK
Applying network.0012_auto_20201207_1341... OK
Applying network.0013_auto_20201207_1931... OK
Applying network.0014_newpost_rating... OK
Applying network.0015_reply... OK
Applying network.0016_auto_20201208_1559...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:\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python38\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python38\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "C:\Python38\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Python38\lib\site-packages\django\core\management\commands\migrate.py", line 231, in handle
post_migrate_state = executor.migrate(
File "C:\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 "C:\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 "C:\Python38\lib\site-packages\django\db\migrations\executor.py", line 245, in apply_migration
state = migration.apply(state, schema_editor)
File "C:\Python38\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:\Python38\lib\site-packages\django\db\migrations\operations\fields.py", line 110, in database_forwards
schema_editor.add_field(
File "C:\Python38\lib\site-packages\django\db\backends\sqlite3\schema.py", line 328, in add_field
self._remake_table(model, create_field=field)
File "C:\Python38\lib\site-packages\django\db\backends\sqlite3\schema.py", line 189, in _remake_table
self.effective_default(create_field)
File "C:\Python38\lib\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 "C:\Python38\lib\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 "C:\Python38\lib\site-packages\django\db\models\fields\__init__.py", line 1376, in get_db_prep_value
value = self.get_prep_value(value)
File "C:\Python38\lib\site-packages\django\db\models\fields\__init__.py", line 1355, in get_prep_value
value = super().get_prep_value(value)
File "C:\Python38\lib\site-packages\django\db\models\fields\__init__.py", line 1215, in get_prep_value
return self.to_python(value)
File "C:\Python38\lib\site-packages\django\db\models\fields\__init__.py", line 1337, in to_python
raise exceptions.ValidationError(
django.core.exceptions.ValidationError: ['“” value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.']
django.contrib.postgres.fields.ArrayField) with SQLite?blank=Trueto yourtimestampcolumn.