‘Django’ Archive

Dockerizing a Django app with scripted super user creation 2018-03-30 No Comments

I recently dockerized a small Django application. I build the Dockerfile in a way that the resulting image would allow running the container as if it was plain manage.py, e.g. that besides docker-compose up I could also do: # For a psql session into the database: docker-compose run <image_name> dbshell # Or, to run the […]

Serving /favicon.ico with Django without HTTP redirection 2018-03-29 No Comments

Say you have created a favicon.ico for your website and want to serve that file outside of the usual /static/images prefix, at /favicon.ico. Other favicon approaches use a code-30x redirect on HTTP level. I would rather save that extra request. Here is what I ended up with: import os from django.conf import settings from django.views.static […]