Deploy ML with Django and Docker, I think it's kinda overkill, but a good learning project This is a more fancy setup, if you just deploy one model (not gonna do anything about, refer to misty_dc_light
- Create venv and install Django
virtualenv env
env\Scripts\activate.bat
pip3 install django
- Start project
cd backend
django-admin startproject mysite
cd mysite folder
pip3 install djangrestframework
pip3 install markdown
pip3 install django-filter
- Start endpoints in the project
python3 manage.py startapp endpoints
- Create apps, put appname in it
- Change apps.py such that it knows we have moved the endpoints directory into apps
class EndpointsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.endpoints'
- Edit apps/endpoints/models.py
- Good time to migrate the fields into the db.
python3 manage.py makemigrations
python3 manage.py migrate
- Add apps/endpoints/serializers.py
- Edit apps/endpoints/views.py
- Add the links to urls
- Edit settings
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'apps.endpoints',
'apps.ml']
ROOT_URLCONF = 'misty_dc.urls'
SECRET_KEY = 'django-insecure-' # delete just for security reason
- Edit asgi.py
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'misty_dc.settings')
- Edit urls.py
from apps.endpoints.urls import urlpatterns as endpoints_urlpatterns
urlpatterns += endpoints_urlpatterns
- Make registry to add connect the ML to server side (the worst nightmare)
- use wsgi.py to add MLAlgorithm