Chapter 5. User Management

User Management Function Development with Django

User Management Function Development with Django
Tag:

The main figure describes key design points in user management function development using the Django framework.

1. models.py

models.py is used to define the structure of the user model. When you use the Django built-in user model, you don't need to add a new user model, but creating a custom model for the future expandability of the user model is recommended.

2. views.py

views.py is the core part of the logic that handles the process of user management. Usually, it is one views.py file per application, but you can separate files to make the coding structure more transparent. There are multiple approaches to developing views, which will be explained in the next section.

3. forms.py

forms.py is used to add data validation for input forms. When you use class-based generic views, you may not use this, but when you want to customize data validation, using forms.py is beneficial.

4. urls.py

urls.py is used to handle URLs to dispatch HTTP requests to related views. Usually, you need to create a urls.py file for user management (e.g., under the account app directory).

5. templates

The templates directory should contain multiple HTML files. User management-related templates are usually stored under the account sub-directory. As there are many steps for user management, you need to manage many template files (e.g., sign-up, login, log-out, and user profile pages).

The main figure describes key design points in user management function development using the Django framework.

1. models.py

models.py is used to define the structure of the user model. When you use the Django built-in user model, you don't need to add a new user model, but creating a custom model for the future expandability of the user model is recommended.

2. views.py

views.py is the core part of the logic that handles the process of user management. Usually, it is one views.py file per application, but you can separate files to make the coding structure more transparent. There are multiple approaches to developing views, which will be explained in the next section.

3. forms.py

forms.py is used to add data validation for input forms. When you use class-based generic views, you may not use this, but when you want to customize data validation, using forms.py is beneficial.

4. urls.py

urls.py is used to handle URLs to dispatch HTTP requests to related views. Usually, you need to create a urls.py file for user management (e.g., under the account app directory).

5. templates

The templates directory should contain multiple HTML files. User management-related templates are usually stored under the account sub-directory. As there are many steps for user management, you need to manage many template files (e.g., sign-up, login, log-out, and user profile pages).

Tag: