Problems with django one-click-app image

February 23, 2018 1.2k views
Django Ubuntu 16.04

So I've spent the whole night to get my existing django project to work with this image. Some problems remained:

  • How to replace python 2 with python 3 and why do you offer python2 as default in 2018??
  • How to rename django_project?
  • Where are configs and log files of all software involved in running django?
  • Why has django to listen on interfaces other that loopback? Isn't it unsecure? And your code to get all interface addresses doesn't find 127.0.0.1 on windows.
  • How to restart django after fixing errors without restarting the whole VM?
  • Why are SFTP operations so hell slow, especially if copying many small files?

Some solutions I've found. Probably they will help others:

  • If you have 504 error, read /var/log/syslog. I did it this way: 7z a /var/log/syslog.7z /var/log/syslog as root and then downloaded /var/log/syslog.7z. You have to install 7zip first.
  • django user need to have at least recursive read permission to /home/django/django_project. I've worked as root. Fixed it with

    # cd /home
    # chown -R django:django django
    
  • You need to add this code from sample project to your setting.py. I don't know why

import netifaces
def ip_addresses():
    ip_list = []
    for interface in netifaces.interfaces():
        addrs = netifaces.ifaddresses(interface)
        for x in (netifaces.AF_INET, netifaces.AF_INET6):
            if x in addrs:
                ip_list.append(addrs[x][0]['addr'])
    return ip_list

# Discover our IP address
ALLOWED_HOSTS = ip_addresses()
1 Answer

Honestly the "one click" Django droplet does not really work, and it's definitely not one click, I was trying to get it working all day, and in the end just started a fresh ubuntu install and set it up myself. I DON'T RECOMMEND using this droplet... Here is a pretty straight forward tutorial http://rahmonov.me/posts/deploy-a-django-app-to-digitalocean/

Have another answer? Share your knowledge.