Published onRaise your hand if you never versioned the Django’s SECRET_KEY at the beginning of a project and needed to generate a new one before going to production. This TLDR is a quick reminder of how to generate a secret key locally, without going to some website on the internet to generate it for you. Django generates a secret key every time that you create a new project, so this function already exists at its code, and you can access it in this way:
Published onChatting with a friend, Mário Sérgio, about problems that happen when you migrate your codebase from Python versions, I came out with the idea of writing this TLDR. I hope it can help someone that is trying to work with texts that contain Unicode characters that don’t fall back into the ASCII table like other than the roman alphabet and emoji. On Python 2 there’s no distinction between byte and string.
Published onSome libraries aren’t 100% packaged Python code, some of them are bindings to external libraries. They offer a Python interface so you can call them inside your code. On these cases, we need to install them previously at the system so the python package can work. When that happens, we get this kind of error: ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3 To solve errors like that, you need to install the external library, and the system configures everything to you.
Published onThis post it the result of a bug that haunted me for three months until I finally could isolate the error properly, and get to the root of the issue. Disclaimer: this information exists at the Django docs, however strengthening the importance of this info is vital to prevent people to spend a lot of time with this kind of bug. One of the core parameters of a Django Model field is the default.
Published onHave you ever asked yourself how to publish your Python package, so you can install it using pip? It is less complex than it seems, and anyone can do it. The first step is to create an account on the Python Package Index (PyPI) were all Python packages are registered. After that, you need to create a file called setup.py on the root folder of the Python code that you will publish with the following content, changing the values were is needed:
Published onRecently someones asked me how to perform a connection to a server to run the command df -h using ssh to display the disk usage of the machine. After a quick chat, I discovered that the question was more than just a single check to a server. It was to extend that to multiple servers. The answer to the question was quick and came with a “click”. How about to document these quick tips at the blog?