Creating user profile pages in Django

后端 未结 2 1272
伪装坚强ぢ
伪装坚强ぢ 2021-01-31 12:51

I\'m a beginner in Django. I need to setup a website, where each user has a profile page. I\'ve seen django admin. The profile page for users, should store some information whic

2条回答
  •  时光取名叫无心
    2021-01-31 13:18

    You can

    • create another Model for storing profile information about user
    • add AUTH_PROFILE_MODULE='yourprofileapp.ProfileModel' to settings.py
    • In profile editing view, allow only logged in users to edit their own profiles

      example:

      @login_required
      def edit_profile(request):
          '''
          edit profile of logged in user i.e request.user
          '''
      
    • You can also make sure that whenever new user is created the user's profile is also created using django's signals

    Read about storing additional information about users from django documentation

提交回复
热议问题