Trouble deploying Django app to Heroku "no Cedar-supported app detected" - python

I've been struggling to deploy a small Django web app following the instructions given here. I've only been using sqlite3 to build my app in my development and everything works fine on the Django development server. When I try to deploy to Heroku, I get the error "Push rejected, no Cedar-supported app detected", but I think I have all the files required to get my app up and running. Been at it for days now with no success so I'll take any suggestions and help. Below is a sketch of my app, but feel free to sift the whole thing at my github repo.
landcrab/
landcrab/ <----- main project
settings/
__init__.py
base.py
local.py
production.py
__init__.py
urls.py
db.sqlite3
wsgi.py
vcrental/ <----- my app
admin.py
....
static/
....
.gitignore
db.sqlite3
manage.py
Procfile
requirements.txt
runtime.txt
In manage.py and wsgi.py I've set os.environ.setdefault("DJANGO_SETTINGS_MODULE", "landcrab.settings.production")
Procfile
web: gunicorn landcrab.wsgi --log-file -
requirements.txt (used pip freeze)
Django==1.7.1
dj-database-url==0.3.0
dj-static==0.0.6
django-toolbelt==0.0.1
gunicorn==19.1.1
jsmin==2.0.11
nose==1.3.4
psycopg2==2.5.4
pyparsing==2.0.3
python-dateutil==2.2
pytz==2014.9
six==1.8.0
static3==0.5.1
runtime.txt
python-3.4.2
For my settings file, I attempted to follow this structure
Production.py
from landcrab.settings.base import *
import dj_database_url
DEBUG = False
TEMPLATE_DEBUG = False
# Parse database configuration from $DATABASE_URL
DATABASES['default'] = dj_database_url.config()
# DATABASES['default'] = dj_database_url.config(default='postgres://user:pass#localhost/dbname')
# DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
# DATABASES = {'default': dj_database_url.config(default=os.environ.get('DATABASE_URL'))}
# DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Allow all host headers
ALLOWED_HOSTS = ['*']
and finally wsgi.py
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "landcrab.settings.production") #Edited by me
from django.core.wsgi import get_wsgi_application
#Added by me for Heroku
try:
from dj_static import Cling
application = Cling(get_wsgi_application())
except:
application = get_wsgi_application()

Well this is embarrassing. I hadn't committed my changes before attempting to deploy to Heroku. After committing, I was able to deploy without error.

Related

Heroku Deployment Issue - No python application found

I run through deploying my heroku app (a flask application) and it successfully deploys. But when I try to open the app I get the below error based on the logs:
--- no python application found, check your startup logs for errors ---
The way I have the app structured with key files/directories:
-Root/
- requirements.txt
- Procfile
- run.py
- MyApp/
-templates/
-static/
-routesFolder/
-__init__.py
-uwsgi.ini
-config.py
I have tried to do a few different things including adjusting the uwsgi.ini file where I had started with module = app:app. Below is my complete uwsgi.ini file.
[uwsgi]
http-socket = :$(PORT)
master = true
die-on-term = true
module = MyApp.uwsgi:application
memory-report = true
Below is my Procfile contents:
web: uwsgi MyApp/uwsgi.ini

Django ModuleNotFoundError: No module named 'mysite.settings' when trying to host application with wsgi server

So I wanted to deploy my first django application on a cherryPy webserver using wsgi. And I have issues with os.environ['DJANGO_SETTINGS_MODULE']. When trying to run application callable it throws error, that module is not found. Project structure:
ResourceManager
ResourceManager
ResourceManager
__init__.py
cherryserver.py
settings.py
urls.py
wsgi.py
SimpleResourceManager
migrations
__init__.py
admin.py
apps.py
models.py
serializers.py
tests.py
urls.py
views.py
manage.py
wsgi.py file:
import os
import sys
from django.core.wsgi import get_wsgi_application
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0,BASE_DIR)
os.environ['DJANGO_SETTINGS_MODULE'] = 'ResourceManager.settings'
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ResourceManager.settings')
application = get_wsgi_application()
cherryserver.py:
import cherrypy
from ResourceManager.ResourceManager.wsgi import application
if __name__ == '__main__':
# Mount the application
cherrypy.tree.graft(application, "/")
# Unsubscribe the default server
cherrypy.server.unsubscribe()
# Instantiate a new server object
server = cherrypy._cpserver.Server()
# Configure the server object
server.socket_host = "0.0.0.0"
server.socket_port = 8080
server.thread_pool = 30
# Subscribe this server
server.subscribe()
cherrypy.engine.start()
cherrypy.engine.block()
Application works fine when using command runserver 8080, but when i tried to run it on different server. It says ModuleNotFoundError: No module named "ResourceManager.settings".
So i tried: Change where cherryserver.py is located in directory, I have added additional lines of code to wsgy.py file and I'm running out of ideas what is wrong when I'm deploying my app on different server. Why I'm using cherryPy, well I have to test 5 web servers that are based on python.
Try changing from:
from ResourceManager.ResourceManager.wsgi import application
To:
from wsgi.py import application
This is because they are located in the same directory, if this does not work just mess around with the from as it seems that your path to the wsgi file is wrong.

ValueError: The file 'css/style.css' could not be found with whitenoise

I am trying to deploy an app using heroku. But for some reason, the static files are not loaded with whitenoise and there is an internal server error message in the browser :
Internal Server Error
The server encountered an unexpected internal
server error (generated by waitress)
In the heroku logs :
ValueError: The file 'css/style.css' could not be found with
whitenoise.django.GzipManifestStaticFilesStorage object at 0x7f5da0186750
Here are some points.
an empty static file (with an empty robots.txt in) is created in the root folder for heroku.
python manage.py runserver : everything works fine. no issue.
heroku local 500 error. (but the view still shows up)
css file path : myhellowebapp/collection/static/css/style.css
both python manage.py collectstatic and heroku run python manage.py collectstatic work just fine.
If I comment out STATICFILES_STORAGE =
'whitenoise.django.GzipManifestStaticFilesStorage',
the error message in the browser disappear and I can see html of the app in the browser, but no css file is attached
So it has to do with whitenoise but no I idea how to fix this.
setting.py:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
...
STATIC_URL = '/static/'
STATIC_ROOT = 'staticfiles'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
settings_production.py :
from hellowebapp.settings import *
...
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
wsgi.py :
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE",
"hellowebapp.settings_production")
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
I've been working this problem for days I tried all the possible solutions that I found online but none of them worked. Can anyone help?
The link to all of my code :
https://github.com/ryuji-the-dragon/hellomyapp

Collectstatic error while deploying Django app to Heroku

I'm trying to deploy a Django app to Heroku, it starts to build, download and installs everything, but that's what I get when it comes to collecting static files
$ python manage.py collectstatic --noinput
remote: Traceback (most recent call last):
remote: File "manage.py", line 10, in <module>
remote: execute_from_command_line(sys.argv)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
remote: utility.execute()
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
remote: self.fetch_command(subcommand).run_from_argv(self.argv)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
remote: self.execute(*args, **cmd_options)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
remote: output = self.handle(*args, **options)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 168, in handle
remote: collected = self.collect()
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 98, in collect
remote: for path, storage in finder.list(self.ignore_patterns):
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 112, in list
remote: for path in utils.get_files(storage, ignore_patterns):
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/utils.py", line 28, in get_files
remote: directories, files = storage.listdir(location)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/files/storage.py", line 300, in listdir
remote: for entry in os.listdir(path):
remote: OSError: [Errno 2] No such file or directory: '/app/blogproject/static'
remote:
remote: ! Error while running '$ python manage.py collectstatic --noinput'.
remote: See traceback above for details.
remote:
remote: You may need to update application code to resolve this error.
remote: Or, you can disable collectstatic for this application:
remote:
remote: $ heroku config:set DISABLE_COLLECTSTATIC=1
remote:
remote: https://devcenter.heroku.com/articles/django-assets
remote:
remote: ! Push rejected, failed to compile Python app
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to pin-a-voyage.
This is the whole settings.py file
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import dj_database_url
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '*********************'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
'custom_user',
'django_markdown',
'parsley',
)
#### AUTH ###
AUTH_USER_MODEL = 'custom_user.CustomUser'
AUTHENTICATION_BACKENDS = (
'custom_user.backends.CustomUserAuth',
'django.contrib.auth.backends.ModelBackend',
# 'django.contrib.auth.backends.RemoteUserBackend',
)
#############
#### EMAIL ###
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = '***' #my gmail password
EMAIL_HOST_USER = 'voyage.pin#gmail.com' #my gmail username
DEFAULT_FROM_EMAIL = 'voyage.pin#gmail.com'
SERVER_EMAIL = 'voyage.pin#gmail.com'
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
##############
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'blogproject.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'blogproject.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'blogproject',
'USER': '***',
'PASSWORD': '***',
'HOST': 'localhost',
'PORT': '',
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Update database configuration with $DATABASE_URL.
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Allow all host headers
ALLOWED_HOSTS = ['*']
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
STATIC_URL = '/static/'
# Extra places for collectstatic to find static files.
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, 'static'),
)
# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
This is the structure of the project
blog-project -- blog -- migrations
-- static
-- templates
-- blogproject
-- blogprojectenv
-- custom_user
-- media
-- .git
Any thoughts?
I just updated to Django 1.10 today and had the exact same problem.
Your static settings are identical to mine as well.
This worked for me, run the following commands:
disable the collectstatic during a deploy
heroku config:set DISABLE_COLLECTSTATIC=1
deploy
git push heroku master
run migrations (django 1.10 added at least one)
heroku run python manage.py migrate
run collectstatic using bower
heroku run 'bower install --config.interactive=false;grunt prep;python manage.py collectstatic --noinput'
enable collecstatic for future deploys
heroku config:unset DISABLE_COLLECTSTATIC
try it on your own (optional)
heroku run python manage.py collectstatic
future deploys should work as normal from now on
You have STATICFILES_DIRS configured to expect a static directory in the same directory as your settings.py file, so make sure it's there not somewhere else.
Also, do you have any files in that static directory? If you don't then git won't track it and so although it exists locally it won't exist in git. The usual solution to this is to create an empty file called .keep in the directory which will ensure that git tracks it. But once you have some static files in this directory then it won't be a problem anymore.
DO NOT disable collectstatic on heroku with heroku config:set DISABLE_COLLECTSTATIC=1. This will just hide the error and not make your app healthy.
Instead, it's better to understand why the collectstatic command fails because it means something is not right with your settings.
Step 1
Run locally both commands:
python manage.py collectstatic
python manage.py test
You should see one or more error messages. Most of the time, it's a missing variable (for ex: STATIC_ROOT) you must add to your project settings.py file.
It's necessary to add the test command because some collectstatic related issues will only surface with test, such as this one
Step 2
Once you've fixed all the error messages locally, push again to heroku.
Troubleshooting
Remember you can also run commands directly in your heroku VM.
If you cannot reproduce locally, run the collecstatic command in heroku and check what's going on directly in your production environment:
python manage.py collectstatic --dry-run --noinput
(Same goes for heroku console obviously)
Run python manage.py collectstatic locally and fix any errors. In my case there were reference errors that prevented that command from running successfully.
if you use django-heroku library
maybe you forget for put this setting in the bottom of line text settings.py for can possible read all config parameters
import django_heroku
django_heroku.settings(locals())
as like as the documentation:
Usage of Django-Heroku
In settings.py, at the very bottom::
…
# Configure Django App for Heroku.
import django_heroku
django_heroku.settings(locals())
This will automatically configure DATABASE_URL, ALLOWED_HOSTS, WhiteNoise (for static assets), Logging, and Heroku CI for your application.
p.s: sorry for my bad english
This error has occurred because you do not have staticfiles in
your Project's Root Directory.
Don't worry. The solution is SIMPLE.
You only need TWO STEPS.
Step 1: Open your settings.py file and write
import os
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent
STATIC_ROOT = BASE_DIR / 'staticfiles'
Step 2: Run below given command in terminal in your Project's root directory.
(If you are using any Virtual environment for Django Project then go inside your Virtual environment and then go into your Project's root directory and then run below given command.)
python manage.py collectstatic
Congrats : Your Problem is Solved.
Now, you can COMMIT and PUSH your "changes" so that it is reflected in your Repository and then you are good to go.
This worked for me:
step 1 - heroku config:set DISABLE_COLLECTSTATIC=1
step 2 - git push heroku master
I face same problem..
Follow this step
heroku config:set DISABLE_COLLECTSTATIC=1
git push heroku master
python manage.py collectstatic
python manage.py test
If any error occurred after running test..check your
STATIC_ROOT is correct like this ==> STATIC_ROOT = os.path.join(BASE_DIR, 'static').
After run collectstatic command check all static files are
store in static directory for your root dir. level(manage.py
dir. level)...
heroku run python manage.py collectstatic.
heroku run python manage.py migrate
heroku config:unset DISABLE_COLLECTSTATIC (for future use).
Heroku had made a document with suggestions on how to handle this https://devcenter.heroku.com/articles/django-assets
add to settings.py
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
make a directory in the root of your project called staticfiles, put a favicon or something in there, just make sure git tracks it. Then the collectstatic command should finish on heroku.
Ran to that issue after trying to deploy an app again. The problem got cured after I specified these commands:
$ heroku config:set SECRET_KEY="*secret_key*"
$ heroku config:set DEBUG_VALUE="True"
$ heroku config:set EMAIL_USER="*user-email*"
$ heroku config:set EMAIL_PASS="*pass*"
These variables in settings.py were invoked with local environment variables,
which heroku didn't have on its environment, hence the error.
It seems to me that it's having problems creating that blogproject/static folder. I see you have a static folder inside your blog app, but it should be up one level in your blogproject folder.
Try creating a static folder inside your blogproject folder and that error should go away.
Today, not all of the requirements came in properly with $ pipenv install django from the heroku-django-template and $ pip install -r requirements.txt.
The latest version of the template includes a /static folder with a humans.txt, so the previous solution is likely not the proplem
Try running $ pipenv install whitenoise and then $ pip freeze > requirements.txt.
If that works, I would recommend $ pip install psycopg2 --ignore-installed and $ pip freeze > requirements.txt as well, otherwise you will similarly have problems migrating.
I faced the same issue while deploying my app. I realized I had updated my pip version, installed few plugins but forgot to create a fresh requirements.txt file.
Run pip freeze > requirements.txt in your terminal
Run python manage.py collectstatic
Now push the code to github and deploy to heroku server
Hope this helps if that is the case
insert this line of code to your setting.py file.
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
In my case was an error almost like described above, after push-ing that resulted in errors, I set the SECRET_KEY "heroku config:set SECRET_KEY='*************************'",
git push heroku main (again)
,
heroku run python manage.py migrate
,
heroku run python manage.py createsuperuser .. and everything
,
heroku open
and it worked :)
removing STATICFILES_DIRS worked in my case
heroku config:set DISABLE_COLLECTSTATIC=1 --app #yourappname
Just run the command
This problem occurs because Heroku tries to run manage.py.
While executing manage.py
we have to write like
python manage.py 'some_command'
But Heroku tries it as
python manage.py --noinput
So in this case we can make changes to our manage.py file:
Initialy it looks like this:
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
'your_project.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv) # just put this in try block
if __name__ == '__main__':
main()
So we change our main.py to:
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
'your_project.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
try:
execute_from_command_line(sys.argv) # just put this in try block
except:
pass
if __name__ == '__main__':
main()
If you used .env files and python-decouple you'll have to define the environmental variables in Heroku app settings > Config Vars. Otherwise collectstatic won't work.
After testing everything that was posted on this thread, here's what worked for me:
Keep the Heroku environment variable DISABLE_COLLECTSTATIC set to 0, as it won't really solve the issue, but just mask it and mess with your site's assets
When using django_heroku lib on the settings file, include the argument "staticfiles=False", like this: django_heroku.settings(locals(), staticfiles=False)
The STATIC_ROOT variable on settings.py should be set as STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles'), being BASE_DIR set as BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))). This is described on Heroku's django-assets doc
After doing all that, run a python manage.py migrateon Heroku CLI and you should see a message about assets downloaded.
Before making it to actually work, the collectstatic command python manage.py collectstatic on Heroku CLI was giving a correct output, so be aware that you may get no errors with this command, but still have something wrong going on.

Hosting Django app with Waitress

I'm trying to host a Django app on my Ubuntu VPS. I've got python, django, and waitress installed and the directories moved over.
I went to the Waitress site ( http://docs.pylonsproject.org/projects/waitress/en/latest/ ) and they said to use it like this:
from waitress import serve
serve(wsgiapp, host='5.5.5.5', port=8080)
Do I put my app name in place of of 'wsiapp'? Do I need to run this in the top-level Django project directory?
Tested with Django 1.9 and Waitress 0.9.0
You can use waitress with your django application by creating a script (e.g., server.py) in your django project root and importing the application variable from wsgi.py module:
yourdjangoproject project root structure
├── manage.py
├── server.py
├── yourdjangoproject
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   ├── wsgi.py
wsgi.py (Updated January 2021 w/ static serving)
This is the default django code for wsgi.py:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "yourdjangoproject.settings")
application = get_wsgi_application()
If you need static file serving, you can edit wsgi.py use something like whitenoise or dj-static for static assets:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "yourdjangoproject.settings")
"""
YOU ONLY NEED ONE OF THESE.
Choose middleware to serve static files.
WhiteNoise seems to be the go-to but I've used dj-static
successfully in many production applications.
"""
# If using WhiteNoise:
from whitenoise import WhiteNoise
application = WhiteNoise(get_wsgi_application())
# If using dj-static:
from dj_static import Cling
application = Cling(get_wsgi_application())
server.py
from waitress import serve
from yourdjangoproject.wsgi import application
if __name__ == '__main__':
serve(application, port='8000')
Usage
Now you can run $ python server.py
I managed to get it working by using a bash script instead of a python call. I made a script called 'startserver.sh' containing the following (replace yourprojectname with your project name obviously):
#!/bin/bash
waitress-serve --port=80 yourprojectname.wsgi:application
I put it in the top-level Django project directory.
Changed the permissions to execute by owner:
chmod 700 startserver.sh
Then I just execute the script on the server:
sudo ./startserver.sh
And that seemed to work just fine.

Categories