ProgrammerInMaking
ProgrammerInMaking

Reputation: 23

Django Application not working when moved to a app server

I have a Django app which works fine on my development machine. But when moved to a different location on app server for hosting, it does not work. The error

django.core.exceptions.ImproperlyConfigured: 'django-pyodbc-azure' isn't an available database backend. Try using 'django.db.backends.XXX', where XXX is one of: 'mysql', 'oracle', 'postgresql', 'sqlite3'

When I run the pip freeze command on command prompt, it does not even show the pyodbc and the other libraries installed. All it shows is Django 2.1,Django ms-sql and pytz.I cannot install the libraries on app server using pip install(prod server. No connection).

The way I am moving my project from dev to prod machine is by compressing the folder, copying it and then decompressing it. Is copying an issue? Am I missing something here.

Any help is appreciated.

Upvotes: 0

Views: 136

Answers (1)

FlipperPA
FlipperPA

Reputation: 14351

If you can't pip install on the production server, how are you pointing your WSGI runner (Apache mod_wsgi, gunicorn, or uwsgi) to a venv?

What you might be able to do is include the venv as part of your Django project. This makes one big assumption: that your development and production environments are compatible. pyodbc is compiled, so for the binaries to work, your environments are going to have to be very similar. If that's the case, here's an example:

cd my_django_project
python -m venv venv
. venv/bin/activate
pip install -r requirements/prod.txt
cd ..
tar -czvf my_django_project.tar.gz my_django_project 

Then copy it to your destination server, and there:

cd /var/django
tar -xzvf ~/my_django_project.tar.gz

Then adjust your production WSGI runner to point its Python path to /var/django/my_django_project/venv.

Upvotes: 0

Related Questions