Forums

Error Deploying Django Website

Hi, I'm trying to deploy my Django website here in pythonanywhere, but got the following error:

<pre><code>Error running WSGI application

2020-07-03 23:43:04,144: TypeError: init() missing 1 required positional argument: 'on_delete'

2020-07-03 23:43:04,144: File "/var/www/aguilacoffee_pythonanywhere_com_wsgi.py", line 56, in <module>

2020-07-03 23:43:04,144: application = get_wsgi_application()

2020-07-03 23:43:04,144:

2020-07-03 23:43:04,144: File "/usr/lib/python3.5/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application

2020-07-03 23:43:04,145: django.setup(set_prefix=False)

2020-07-03 23:43:04,145:

2020-07-03 23:43:04,145: File "/usr/lib/python3.5/site-packages/django/init.py", line 24, in setup

2020-07-03 23:43:04,145: apps.populate(settings.INSTALLED_APPS) 2020-07-03 23:43:04,145:

2020-07-03 23:43:04,145: File "/usr/lib/python3.5/site-packages/django/apps/registry.py", line 114, in populate

2020-07-03 23:43:04,145: app_config.import_models()

2020-07-03 23:43:04,146:

2020-07-03 23:43:04,146: File "/usr/lib/python3.5/site-packages/django/apps/config.py", line 211, in import_models

2020-07-03 23:43:04,146: self.models_module = import_module(models_module_name)

2020-07-03 23:43:04,146:

2020-07-03 23:43:04,146: File "./basic_app/models.py", line 6, in <module>

2020-07-03 23:43:04,146: class UserProfileInfo(models.Model):

2020-07-03 23:43:04,146:

2020-07-03 23:43:04,147: File "./basic_app/models.py", line 7, in UserProfileInfo

2020-07-03 23:43:04,147: user=models.OneToOneField(User)</code></pre>

I followed these tutorials to make the deploy: <ul> <li>https://help.pythonanywhere.com/pages/DebuggingImportError/</li> <li>https://help.pythonanywhere.com/pages/DeployExistingDjangoProject/</li> <li>https://help.pythonanywhere.com/pages/environment-variables-for-web-apps</li> <li>https://help.pythonanywhere.com/pages/DjangoStaticFiles</li> </ul>

Any help will be appreciated, thank you!

It looks like you're trying to run code that was written for one version of Django in a different version of Django. Make sure that the version of Django that you're using in your web app is the same as the one that the code was intended for.

Hi, thanks for replying so quickly! I already checked and I have installed the same Django version in both (2.2.8).

Any ideas???

Since Django 2.0 you have to provide the on_delete argument for ForeignKey and OneToOneField.

Take a look at https://docs.djangoproject.com/en/2.2/ref/models/fields/#django.db.models.ForeignKey.on_delete