‘Python’ 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 […]

How to deal with “Not uninstalling pip at /usr/lib/python2.7/dist-packages, owned by OS” 2018-03-01 No Comments

When system-wide pip turns out too old (e.g. for lacking support for pip check), one may end up trying to update pip using a command like: sudo pip install –upgrade pip That’s likely to end up with this message: Not uninstalling pip at /usr/lib/python2.7/dist-packages, owned by OS That non-error and the confusion that easily happens […]