I have extended the Django User model as per the docs: https://docs.djangoproject.com/en/1.8/topics/auth/customizing/
models.py:
from django.db import models
from django.contrib.auth.models import User
class Onboarding(models.Model):
user = models.OneToOneField(User)
onboarding_status = models.SmallIntegerField(max_length=1, default=1)
views.py:
from django.shortcuts import render
from django.contrib.auth.models import User
from .models import Onboarding
def home(request):
current_user = request.user
u = User.objects.get(id=current_user.id)
onboarding_status = u.onboarding.onboarding_status
context = {
}
if onboarding_status == 1:
return render(request, "onboarding/step_1.html", context)
else:
return render(request, "onboarding/step_2.html", context)
However, I get an error RelatedObjectDoesNotExist at /onboarding/
. User has no onboarding.
How do I accurately reference the onboarding_status integer I have associated with the user from a view?