Kegbot server issues when DEBUG = False

Good Morning,

I am in the process of moving my kegbot setup from the beta cloud back to my on premise environment and I am running into an odd issue. For the base kegbot server setup (pre nginx) when I run my setup with DEBUG = False in local_settings.py the website is “broken”. All the text is there but the formatting is gone and my logging is filled with 404 errors. When I set it to DEBUG = True, everything looks and functions properly. What am I missing here?

Thanks!!!
Jeff

I’ve run into the same issue, but I can’t yet tell you how to fix it, but I can tell you why it happens. Django doesn’t serve files from /static/ because it’s insecure. When you set it to DEBUG = True, it serves up the files, but DEBUG = False means it stops serving the static files because users can see it. I think.

https://docs.djangoproject.com/en/dev/howto/static-files/

django offers some solutions for deployment here:
https://docs.djangoproject.com/en/dev/howto/static-files/deployment/

All of this may as well be Cantonese to me, but I’m learning it.

I’m honestly considering moving the static files to the templates folder, and just changing the {{STATIC_URL}} markers in the html templates to point to the new folders. (probably a terrible idea.)

I know there’s a better solution, though. I’m not yet terribly familiar with linux as this is my first foray into it.

Okay well at least that’s a start… I don’t recall having this issue before when I had my kegbot server on premise. I’ll keep looking into it…

Thanks
Jeff

Okay so my apologies on my fuzzy memory but now that nginx is all setup this no longer matters…

You may close…

Thanks!!!
Jeff

I realize this is reviving a very old thread, but I spent some time researching today and wanted to note what I learned for someone who may be more skilled than me in Django / Python in the future.

These notes come from using the docker verison on Github.

The image files that break are served primarily from two template files I can see:

/app/pykeg/web/kegweb/templates/kegweb/includes/tap_snapshot.html and
/app/pykeg/web/kegweb/templates/kegweb/keg-snapshot.html

The image files are linked to with this code:

{% if keg.type.picture %}

<img class="tap-snapshot-image" src="{{ keg.type.picture.resized.url }}">

{% else %}

<img class="tap-snapshot-image" src={% static "images/kegbot-unknown-square.png" %}>

{% endif %}

Although the default image is served from the static directory, any user saved images come from the media directory, and I cannot find a conversion function anywhere in the code to collect user-uploaded images and copy them to the static folder location (and to update the links on pages like these). As a result, user generated images break when KEGBOT_ENV=production.

Summary… don’t turn off debug mode if you want custom images to work in the web UI…

If anyone knows of another solution, I’d be happy to hear how you figured it out.