Kaizen Today I Learned by Ville Säävuori

Posts tagged django

Weeknotes 2022/17 - Software Architecture: Splitting Up Large Projects

Most non-trivial real life production apps usually require an order of magnitude more planning and configuring than the simple templates from where most projects are started from. I spent the last week testing and planning out the final configuration which would be best suited for an Django app with Vue frontend.

· Read the full article →

Encrypted Data Archives With Django And Backblaze B2

I needed to implement user data export feature to a Django project. The static and user media is handled by Backblaze B2 cloud storage (similar to Amazon S3) which also supports server side encryption that allows your data to be encrypted at rest. Usually when working with filed in Django you want to use the native storage api and storage backends.

· Read the full article →

Migrating to a Custom Django User Model Mid-Project

Using a custom user model in a Django project is almost always a good idea. The documentation for adding one when starting a project is good and clear but switching to a custom model mid-project is not that easy. This blog post explains one way, and ticket #25313 has several helpful comments.

· Read the full article →

How to migrate MySQL database to PostgreSQL

I’ve migrated a couple of old Django projects from MySQL to PostgreSQL lately and decided to document the process here to help make it go faster in the future. If your old database is not exotic in any way the migration process is pretty fast and simple. The hard part is figuring out how and how much you should tweak in the old database to get rid of warnings/errors if there are some.

· Read the full article →

Casting Types With MyPy

Typing in Python is not yet very mature. This small example displays several issues: if request.user.is_authenticated: return JsonResponse( { "user": { "uid": request.user.uid, "username": request.user.username, "email": request.user.email, } } ) The original type of request.user is Union[AbstractBaseUser, AnonymousUser] (which itself is already wrong; the user is actually a Django model that inherits from AbstractBaseUser, not AbstractBaseUser).

· Read the full article →