我正在尝试使用Django在应用程序中进行简单的登录,并使用Amazon Linux在AWS上托管它 我的模特是
class Work(models.Model):
user = models.CharField(_("User"), max_length = 50, default = None)
intern = models.ForeignKey("Intern", default = 1)
date = models.DateField(_("Date"), default= timezone.now().today(), blank=True)
time_in = models.TimeField(_("Time In"),default= timezone.now().time(), blank=True)
time_out = models.TimeField(_("Time Out"),default= timezone.now().time(), blank=True)
我已经尝试过timezone.now()。time和datetime.datetime.now()。time()并且没有这些工作
当我尝试在服务器上运行迁移时,我收到此错误日志
Apply all migrations: admin, auth, clockin, contenttypes, database, sessions, watson
Running migrations:
Applying clockin.0006_auto_20170523_1101...System check identified some issues:
WARNINGS:
clockin.Work.date: (fields.W161) Fixed default value provided.
HINT: It seems you set a fixed date / time / datetime value as default for this field. This may not be what you want. If you want to have the current date as default, use `django.utils.timezone.now`
Traceback (most recent call last):
File "pmi_alpha/manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/opt/python/run/venv/local/lib/python3.4/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 "/opt/python/run/venv/local/lib/python3.4/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 "/opt/python/run/venv/local/lib/python3.4/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/db/migrations/operations/fields.py", line 204, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/db/backends/base/schema.py", line 495, in alter_field
old_db_params, new_db_params, strict)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/db/backends/base/schema.py", line 578, in _alter_field
new_default = self.effective_default(new_field)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/db/backends/base/schema.py", line 199, in effective_default
default = field.get_default()
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/db/models/fields/__init__.py", line 769, in get_default
return self.default()
TypeError: localtime() missing 1 required positional argument: 'value'
(ElasticBeanstalk::ExternalInvocationError)
答案 0 :(得分:0)
对我来说,这似乎是我用作数据库的mySQL的一个问题。我通过移动到默认的sqlLite文件解决了这个问题。