2👍
✅
you are missing a pair of brackets in your code example, does this work?
url (
r'^question_detail-(?P<pk>\w+)$',
user_passes_test(not_in_group_chef, login_url='public_connexion')(
Question_detail.as_view()
),
name='detail_question'
)
0👍
Anentropic was right, thank you !
For someone as the same problem:
The second problem that I solved is: for anonymous users, the not_in_group_chef function should verify if the user is registered. That way you won’t get an error for anonymous users.
def not_in_group_chef(user):
if user:
retour = False
if User.objects.filter(username = user).count()==1:
utilisateur = User.objects.get(username = user)
if utilisateur.groups.filter(name='chef').count()==0:
retour = True
return retour
return retour
return False
- [Answered ]-Class based views and 'raise NotImplementedError'
- [Answered ]-Better Alternative to django.contrib.comments
- [Answered ]-How to make an object JSON serializable
- [Answered ]-I'm having trouble deciding between using a foreign key, many-to-many field, or choicefield
- [Answered ]-How to save data into foriegn key in django
Source:stackexchange.com