Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Example Analysis of user account and profile profile in Django

Shulou Source: shulou.com Published: 2022-06-01 15:04:06 10月01日 Update

This article introduces the example analysis of user accounts and profile portraits in Django, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.

Today, let's start with the display of user account information and personal avatars in the blog project: first, create a new folder media under django_project to store avatar files, and store avatars uploaded by users in the new profile_pics folder under media:

Modify django_project/users/models.py to add model class personal information:

Under the django_project folder command line, execute python manage.py makemigrations to create the migration, and perform the migration python manage.py migrate:

Modify the django_project/users/admin.py and register for Profile:

Run project access login http://127.0.0.1:8000/admin:

Click Profile to add an avatar for the user's yale:

The avatar will be uploaded to the django_project/media/profile_pics folder.

Use yale to log in to the system to view personal information:

Modify django_project/django_project/urls.py to add avatar access path rules:

Add signals.py under django_project\ user, and specify upload avatar when you register:

Modify django_project\ user\ apps.py to introduce signals.py:

Run the project, register a user tbag, log in and access your personal information:

This is the end of the sample analysis of user accounts and profile portraits in Django. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Avatars users individuals files information folders projects logins profiles accounts examples data analysis content pictures more help run good next Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB vpn Apple Redmi NVidia