๐ฆ๏ธ ๐ ๐ธ ๐ฑ Spring of Django ๐ฆ๏ธ ๐ ๐ธ ๐ฑ
Posted on May 9th, 2022
Youโve now seen how to handle data in a Django application with basic operations in these CRUD categories:
- Create - when we add a new model instance to the database
- Read - when we query the database to look up existing data
- Update - when we query the database to find existing data so we can change it
- Destroy - when we find existing data in the database and delete it
At the heart of many web applications youโll find variations on this theme, so weโll continue to practice it.
Today weโll add in another essential part of web applications: user registration and login. This will allow us to create users for our application, let them log in (and out) and associate data with specific users.
๐ Django Music Project Review
- ๐ฒ What was one AHA! moment you had?
- โฒ๏ธ What did you spend the most time on?
- ๐ What is something that youโd like to understand better?
- ๐ What are three goals that you have set for yourself for this next assignment?
๐ฏ Project: Django Freeshelf
This is a 3-day assignment that youโll work on this week. It is due on Thursday Morning, May 12. We will do end-of-phase presentations in the afternoon.
๐ Resources
Authentication, Registration, and the User Model in Django
- django-registration-redux
- We are using the simple (one-step) backend
- Simple Is Better Than Complex: How to Extend the Django User Model
- Clear comparison of the four choices you have, and when you would use each one.
- Django docs: User Authentication
- Django docs: built-in User Model -> documentation for all the things you get for free with the User from Django
- Django docs: Extending the built-in User Model with AbstractUser
- Django Best Practices: Custom User Model -> This tutorial is good to read for an overview, but you donโt need to follow the instructions to implement the forms to create or change a user, since we are using the
django-registration-redux
package for that.
- Django Best Practices: Custom User Model -> This tutorial is good to read for an overview, but you donโt need to follow the instructions to implement the forms to create or change a user, since we are using the
- Django docs: Authentication in Web Requests ->
django-registration-redux
handles some of this for us (giving us the login and logout urls, for instance) but itโs helpful to see other ways you can use the authenticated user. - The
login_required
decorator - Limiting access to logged-in users that pass a test
Related Python & Django resources
- RealPython: What is a decorator?
- Python dependency management overview -> A good read to understand
pip
,pyenv
, andpipenv
better. - ๐ฅ Django Cheatsheet!
- ๐ซ Django Chat Podcast: How Django Experts Think -> Worth a listen, especially if youโre feeling discouraged about ever learning Django, and super relevant.