Today I replaced MembershipNerd’s default django user model with a custom user model, in order to authenticate user’s by their email, not some username. The reason for this should be obvious: The primary purpose of MembershipNerd is to allow people to sign-up for updates via email. So we definitely need their email address. Anything else is optional.
The django-improved-user library that I am using provides the following user attributes (besides the django permissions, groups etc.):
- email address (required)
- password (required)
- short name (optional)
- full name (optional)
The email and password are required because they are used for authentication. The two other attributes are optional. Removing these two fields would require extra work on my part, and I am wondering if I should just leave them in, without using them. This would mean that the database would have two empty fields for each user entry. Not a big deal. But it would also add some complexity for someone who wants to use and extend MembershipNerd. They need to investigate why the user model has these two optional, but seemingly unused fields. They might wonder if they can safely remove them or if that will break something. (By the way: That someone can also be me in the future.)
Reducing this complexity for someone – maybe even my future self – who tries to understand the code base is more important than the extra work or the empty database fields. So I decided that I will be removing the two optional fields.
This leaves us with:
The MembershipNerd user model
- email address (required)
- password (required)
If you liked this post, please, do share it:
Thanks, for reading (and sharing)! 🥳