Django and Python | Tips and utilities
61 subscribers
24 photos
14 links
Download Telegram
Check if your file name is an image with mimetypes.


#python #django
When dealing with the Django signals framework I use to use the instance method refresh_from_db in combination with a "stop" statement in order to stop the signal from being triggered.

#django #python
In some cases, I don't want to spend time registering models when I am in an early development phase of a Django project.

I let Django register my models in the admin site on the fly.

#python #django
When dealing with many models in a Django app and with a lot of help text for each field, I create a "help text" module to keep my code cleaner.

Also, I standardize the max length of the character fields.

#python #django
If you need to change a virtual environment variable from your .env file, you can use this code.

Place it under utils/env.py or in a similar module.

#django #python #djangotricks