Question

I've put myself into somewhat of a pickle. I use django-registration often, and it seems to work for most situations. However, I want to require users to build their profile (eg: demographic information) before they can visit any of the other pages.

This is how I desire the current setup to run:

  1. visitor fills out registration form --(submit)--->
  2. user email verification --(link creates active user)--->
  3. --(redirected to profile view)--->
  4. user fills out profile form --(submit)-->
  5. user can now access the rest of the website

Is there a recommended way to do this?

Was it helpful?

Solution

One of the ways of doing it would be to use your own @profile_required decorator rather than the django's built in login_required on all your views.

@login_required
def profile_required(func,request,*args,**kwargs):
    has_profile = request.user.profile_set.count()
    if not has_profile:
        return redirect('create_profile')
    return func(request,*args,**kwargs)

Then on each view you want to have a user with profile visit, just:

@profile_required
def my_awesome_view(request):
    ...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top