reading notes for code fellows
If we’re going to deploy actual django apps, it’s important to user customer user models according to the django documentation.
Django comes with a built in user model, but it highly recommends using a customer user model instead to have greater flexibility on real world projects. There are two ways to create a custom user model in Django, AbstractUser and AbstractBaseUser, both can be subclassed, but AbstractBaseUser requires far more work. To create the initial custom user model, you need to update the AUTH_USER_MODEL to use your model instead of the built-in one in the settings. Then, you will need to update the models file in your app with your new CustomUser. You will want to create a new file in your app called forms.py and there you can put together customer user creation and editing forms, though you will most likely want to subclass the existing forms and use similar code. Then in admin, you will put together the class for an Admin user and will register both user creating classes. Then you can make your migration for you app and run migrate to get everything running properly. Now, at the bottom of the settings file, you can also add login and logout redirect paths. If you want to have content that only shows up based on whether a user is authenticated or not, you can use if user.is_authenticated in your templates.
In the video, it was mentioned that if you ran the migrations before updating the base user class you would run into trouble, I’d like to know more about how to work with migrations to better avoid possible problems such as this.