Eduardo Zepeda's latests posts
Mexico Postal codes API with Django
- django
Do you need to get the data associated with a postal code in Mexico for your Django application? I wrote a small library called django-postalcodes-mexico that downloads postal codes from SEPOMEX (México’s Postal Codes official site) and creates an API endpoint that allows y...
Read more
Django and htmx, modern web apps without writing JS
- django
- htmx
The other day I was testing a library called htmx, which promises to make web creation much easier, yes, another library, but with the difference that this one doesn’t need you to write Javascript (JS) and it also combines quite well with Django. Htmx bases all its operatio...
Read more
Django Rest Framework and JWT to authenticate users
- django
- javascript
JWTs (JSON Web Tokens) have become extremely popular, some even consider them a replacement for the classic tokens used by other frameworks, such as the Django Rest Framework. Using JWT or regular tokens (SWT) allows you to store all your session information directly on the token...
Read more
Managers or custom handlers in Django
- django
A Manager (or handler) is the interface through which query operations or queries from the database are provided to Django models. Yes, I mean that objects that goes after the name of your model; YourModel.objects.all() and Tumodel.objects.filter(). All Django models have at leas...
Read more
Trigrams and advanced searches with Django and Postgres
- django
- databases
- django
What if a user’s finger slips on the keyboard and types “parfume” instead of “perfume”. We probably don’t want our user to leave the site because he didn’t find any “parfume” on our website. Our website should return the resul...
Read more
Full text search and searches with Django and Postgres
- django
Sometimes when we type we make a mistake in a letter, we can repeat it, omit it or change it for another one. That mistake can lead to a series of different results in a web search, or even no results at all. Maybe for a blog it does not represent a threat, but for an ecommerce i...
Read more
Ngrok, your localhost accessible from the internet
- linux and devops
I ran into Ngrok trying to redirect a Mercado Pago payment notification to my localhost, for testing purposes. It worked more or less like this: Mercado Pago gave you a url address to redirect the buyer to make the payment. Once the payment was finished, Mercado Pago would make a...
Read more
How do permissions and its groups work in Django?
- django
When I first learned that Django had a permissions system, many years ago, it seemed rather esoteric, not very useful and easy to replicate, how wrong I was back then. Then I realized that the built-in permissions system was a marvel and saved a lot of code, and was quite robust ...
Read more
Don't make this mistake using arrays in Python
- python
The other day I was solving a kata in codewars , one of the steps of the problem needed a two-dimensional array, in more mundane words: an array of arrays. In Python it is super simple to create a two-dimensional array using the multiplication operator, as if it were numbers.
...
Read more
How to upload multiple images in Django
- django
You probably already know how to upload an image using a Django model, but what if we don’t want to upload one but multiple images?
Django installation First we install Django using pipenv. We will also install Pillow since we will be dealing with images.
pip instal...
Read more