Docker Breaks the Old Solution
I generally put something like this in settings.py: import socket try: HOSTNAME = socket.gethostname() except: HOSTNAME = 'localhost' Your solution does not work, if you use Docker. It will show the container ID instead of the URL. My solution was written before Docker existed. Sorry.
A Stack Overflow-style question shows a Python hostname workaround that defaults to “localhost.” The joke is that Docker changes the hostname to a container ID, while the commenter dismisses the criticism by saying the code predates Docker. It is used as a reaction to old code that worked perfectly until modern infrastructure broke its assumptions. EN: A Stack Overflow-style question shows a Python hostname workaround that defaults to “localhost.” The joke is that Docker changes the hostname to a container ID, while the commenter dismisses the criticism by saying the code predates Docker. It is used as a reaction to old code that worked perfectly until modern infrastructure broke its assumptions.
code snippet / фрагмент кодаPython code / код на Pythoncomputer screen / экран компьютераStack Overflow page / страница Stack Overflowupvote arrows / стрелки голосованияgreen check mark / зелёная галочкаcomment section / раздел комментариевDocker container / контейнер Dockerhostname / имя хостаlocalhost string / строка localhostsettings.py file / файл settings.pyprogramming text / текст о программировании
- @ithueti / 3048 2020-11-02
- Type
- image
- Size
- 800×358 · 32.9 KiB
- Mood
- sarcastic, nerdy
- Language
- en
- Added