Django

TLDR: Generate Django Secret Key

Published on

TLDR: Generate Django Secret Key
Raise 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:

TLDR: Setting mutable objects at Django Model Field default

Published on

TLDR: Setting mutable objects at Django Model Field default
This 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.

JWT Authentication with Angular and Django

Published on

JWT Authentication with Angular and Django
Almost every system that runs on the internet and stores user data has an authentication layer. With the API architecture becoming popular nowadays, the complexity of the authentication layer also grew. This post was made to explain the authentication process between a frontend written in Angular 6 and a backend written in Django 2 using the architecture proposed on my previous post “Separating Frontend from Backend with Angular and Django”.

Separating Frontend from Backend with Angular and Django

Published on

Separating Frontend from Backend with Angular and Django
At web development, things evolve and grow in complexity faster than we can follow. That old way of creating websites where the pages were built only with HTML and if you had to change something you had to go through many pages changing the same thing is something rare nowadays. Now, even to create static websites, we use tools to optimize our work. On the last years, we had an increase in javascript frameworks and an excellent evolution on the frontend as a whole.

Django Generic ManyToMany Relations

Published on

Django Generic ManyToMany Relations
Django’s official documentation nicely covers its generic relationship functionality when you have to make an OneToMany (one-to-many or 1:N) relation, but when you need to implement a generic ManyToMany (many-to-many or N:N) relation, there is not much documentation about it. I recently had to implement an N:N with a generic side, and discovered a library called django-gm2m that was very useful to me in this task, and I will describe here giving tips on how to make this implementation and how to avoid possible headaches.