[Answer]-Limit a view in Django

1👍

Without knowing a specific Django solution I can help you with a Python solution. If you use decorators you can limit the access to the webuser view:

# Decorator for limit access when user dont have relation with WebUser
def webuser_required(f):
    def trace(*args, **kw):
        try:
            login = isinstance(request.user.webuser, WebUser)
            return f(*args, **kw)
        except:
            return ....
    return trace

You can use it:

@webuser_required
def yourview(....):
    yourcode

0👍

def limited_view(request):
   if request.user.is_authenticated(): 
      if request.user.web_profile is not None:
          # show 
      else: 
          # dont show 

do you mean something like this?

Leave a comment