Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RelatedObjectDoesNotExist: User has no profile #1

Open
hanzhichao opened this issue Apr 9, 2019 · 3 comments
Open

RelatedObjectDoesNotExist: User has no profile #1

hanzhichao opened this issue Apr 9, 2019 · 3 comments

Comments

@hanzhichao
Copy link

hanzhichao commented Apr 9, 2019

When I run clone your project and run it in python3+django2.1 after migrate, this exception is shown:

django.contrib.auth.models.User.profile.RelatedObjectDoesNotExist: User has no profile.

exception from views.py: line 25:

            if request.user.profile.security_clearance in model.get_create_roles(): 
@BukhosiMoyo
Copy link

BukhosiMoyo commented Jul 14, 2020

I'm a bit kinda late for this but ill just, share the solution that worked for me on Django 3.0.8...

Error : RelatedObjectDoesNotExist: User has no profile

This the is where my error was directing me to :

**@login_required**
def dashboard(request):
    if request.method == 'POST':
        user_form = UserEditForm(instance=request.user, data=request.POST)
        profile_form = ProfileEditForm(instance=request.user.profile, data=request.POST, files=request.FILES)

Note: You have to login or your profile to be saved.

Just after creating your account, you should be able to see that you are not logged in and you will have to log in to for your profile be saved and to start working.

@BlackSpartan
Copy link

@BukhosiMoyo thank you it worked for me.

@barkot01
Copy link

Thank you it worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants