部署到heroku但不在本地时,函数中缺少参数

时间:2018-05-21 19:49:23

标签: python django heroku

我正在尝试将django应用程序部署到heroku。但是当我输入git push heroku master时,我会在调用python manage.py collectstatic --noinput时收到以下错误。

回溯

remote: -----> $ python orphantracker/orphanapp/manage.py collectstatic --noinput
remote:        Traceback (most recent call last):
remote:          File "orphantracker/orphanapp/manage.py", line 15, in <module>
remote:            execute_from_command_line(sys.argv)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
remote:            utility.execute()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 347, in execute
remote:            django.setup()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
remote:            apps.populate(settings.INSTALLED_APPS)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 112, in populate
remote:            app_config.import_models()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models
remote:            self.models_module = import_module(models_module_name)
remote:          File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
remote:            return _bootstrap._gcd_import(name[level:], package, level)
remote:          File "<frozen importlib._bootstrap>", line 994, in _gcd_import
remote:          File "<frozen importlib._bootstrap>", line 971, in _find_and_load
remote:          File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
remote:          File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
remote:          File "<frozen importlib._bootstrap_external>", line 678, in exec_module
remote:          File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
remote:          File "/tmp/build_cac61d0e2017a75936388434ce352671/orphantracker/orphanapp/orphans/models.py", line 6, in <module>
remote:            from audit_log.models.fields import LastUserField, LastSessionKeyField
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/audit_log/models/__init__.py", line 5, in <module>
remote:            class AuthStampedModel(Model):
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/audit_log/models/__init__.py", line 10, in AuthStampedModel
remote:            created_by = CreatingUserField(verbose_name = _("created by"), related_name = "created_%(app_label)s_%(class)s_set")
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/audit_log/models/fields.py", line 14, in __init__
remote:            super(LastUserField, self).__init__(to = to, null = null, editable = editable, **kwargs)
remote:        TypeError: __init__() missing 1 required positional argument: 'on_delete'

错误消息是在fields.py中说我缺少on_delete。但是当我看到有问题的文件时。该领域就在那里。

fields.py

class LastUserField(models.ForeignKey):
    """
    A field that keeps the last user that saved an instance
    of a model. None will be the value for AnonymousUser.
    """

    def __init__(self, to=getattr(settings, 'AUTH_USER_MODEL', 'auth.User'), on_delete=models.SET_NULL, null=True, editable=False,  **kwargs):
        super(LastUserField, self).__init__(to=to, on_delete=on_delete, null=null, editable=editable, **kwargs)

    def contribute_to_class(self, cls, name):
        super(LastUserField, self).contribute_to_class(cls, name)
        registry = registration.FieldRegistry(self.__class__)
        registry.add_field(cls, self)

所以我想知道为什么当我尝试部署到heroku时它没有显示出来。也许我可能会django-audit-log跟踪谁最后一次编辑模型,或者它可能是heroku的问题。

我还应该提一下,该应用程序可以在我的计算机上运行,​​当我运行heroku local时。 python manage.py collectsatic --noinput在本地也可以正常使用。

1 个答案:

答案 0 :(得分:0)

这绝对是django-audit-logs,如您在“回溯”中所见。

https://github.com/vvangelovski/django-audit-log/pull/56

该项目似乎已经过时了