Re:Harmful Defaults in Django
by spookylukey on Friday January 07, 2022 @04:49AM
(#29837171)
The default user model is fine, but I *always* start a project by extending it, for future-proofing. If you need to add to it, this is *so* much better than having to add a one-to-one, and at *some* point down the line you find you do want to add something. The problem is that doing it later when you need it is a pain, because of poor support by the migrations framework.
It's like 4 lines of code that saves you so much grief later on:
from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
pass
AUTH_USER_MODEL = "myapp.User"
If you never need it, those 3 lines are not hurting you. In terms of a default, I think it probably would be nicer if Django pushed you to do this up front.
Re:Harmful Defaults in Django
by cessor on Friday January 07, 2022 @05:07AM
(#29837327)
I agree 100%. Even if you don't need it, these lines don't hurt you, but most of the time, the additional model is put to good use. I usually add metadata, such as additional timestamps, flags, tags, custom user settings, consent or preferences.
It's like 4 lines of code that saves you so much grief later on:
If you never need it, those 3 lines are not hurting you. In terms of a default, I think it probably would be nicer if Django pushed you to do this up front.