Let me describe my scenario.

I got some views that I want to check two conditions before render:
  1. user is logged in
  2. user fulfilled account details form

If user is not logged in -> redirect to login page.
If user have not fulfilled its account details -> redirect to the form page.

I'm using the *LoginRequiredMixin* to check 1 and the *UserPassesTest* to 
check 2 and the problem is that both mixins use the same login_url 
attribute (or method if I implement get_login_url) and as my views include 
both mixins, it always takes the most-left mixin login_url.

Here's my code:
class LoginRequired(LoginRequiredMixin):
    login_url = 'website:join'
    redirect_field_name = None

class FulfillAccountRequired(UserPassesTestMixin):
    login_url = 'website:account-detail'
    
    def test_func(self):
        ...

class MyView(FulfillAccountRequired, LoginRequired, ListView):
    ...

Would be nice if there's a way to set a callable name for login_url (which 
after diving into mixins source I think is not possible).

Is there another clean way to go through?

Thanks,

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/38bf4607-8ca2-4ee4-9065-9dfa353e5fcf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to