python - migrate error with Django 1.7 while adding new model -
i created new model names join 3 fields, email, timestamp , updated timestamp. but, databse sync started giving me error add default values create table. added random values , has started giving me totally random errors beyond understanding. please here.
here's model:
class join(models.model): email = models.emailfield(default="default@default.com") timestamp = models.datetimefield(auto_now_add=true, auto_now=false, default = "") updated = models.datetimefield(auto_now_add=false, auto_now=true) def __unicode__(self): return self.email
and here's error:
(learn_django) c:\users\ajhavery\desktop\learn_django\source>python manage.py ma kemigrations migrations 'joins': 0004_auto_20150320_2358.py: - alter field timestamp on join - alter field updated on join (learn_django) c:\users\ajhavery\desktop\learn_django\source>python manage.py mi grate operations perform: apply migrations: admin, contenttypes, joins, auth, sessions running migrations: applying joins.0002_auto_20150320_2346...traceback (most recent call last): file "manage.py", line 10, in <module> execute_from_command_line(sys.argv) file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\core\man agement\__init__.py", line 385, in execute_from_command_line utility.execute() file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\core\man agement\__init__.py", line 377, in execute self.fetch_command(subcommand).run_from_argv(self.argv) file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\core\man agement\base.py", line 288, in run_from_argv self.execute(*args, **options.__dict__) file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\core\man agement\base.py", line 338, in execute output = self.handle(*args, **options) file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\core\man agement\commands\migrate.py", line 161, in handle executor.migrate(targets, plan, fake=options.get("fake", false)) file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\db\migra tions\executor.py", line 68, in migrate self.apply_migration(migration, fake=fake) file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\db\migra tions\executor.py", line 102, in apply_migration migration.apply(project_state, schema_editor) file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\db\migra tions\migration.py", line 108, in apply operation.database_forwards(self.app_label, schema_editor, project_state, ne w_state) file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\db\migra tions\operations\fields.py", line 37, in database_forwards field, file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\db\backe nds\sqlite3\schema.py", line 179, in add_field self._remake_table(model, create_fields=[field]) file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\db\backe nds\sqlite3\schema.py", line 75, in _remake_table self.effective_default(field) file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\db\backe nds\schema.py", line 188, in effective_default default = field.get_db_prep_save(default, self.connection) file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\db\model s\fields\__init__.py", line 627, in get_db_prep_save prepared=false) file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\db\model s\fields\__init__.py", line 1290, in get_db_prep_value value = self.get_prep_value(value) file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\db\model s\fields\__init__.py", line 1269, in get_prep_value value = super(datetimefield, self).get_prep_value(value) file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\db\model s\fields\__init__.py", line 1171, in get_prep_value return self.to_python(value) file "c:\users\ajhavery\desktop\learn_django\lib\site-packages\django\db\model s\fields\__init__.py", line 1252, in to_python params={'value': value}, django.core.exceptions.validationerror: [u"'00:00:00' value has invalid forma t. must in yyyy-mm-dd hh:mm[:ss[.uuuuuu]][tz] format."]
any please.
when django asks "add default values create table", need create values resonate type of particular column.
your error apparent here: django.core.exceptions.validationerror: [u"'00:00:00' value has invalid format. must in yyyy-mm-dd hh:mm[:ss[.uuuuuu]][tz] format."]
the "random" values entered must in yyyy-mm-dd hh:mm[:ss[.uuuuuu]][tz] format.
remove datetimefields model, remigrate, , start over. time, when you're asked put in default values, put random 'datetime' (i.e. 2006-10-25 14:30:59).
source: https://docs.djangoproject.com/en/1.7/ref/forms/fields/#datetimefield
best, aj
Comments
Post a Comment