Programming experts, hello! ;) I am a newbie in django programming and i can't find any relevant information about how to get a list of users by their permissions. I have spend literally like two hours looking all over the web and there are a lot of similar questions, but none of them is understandable how to use. What i need is to get a list of users with admin permissions in my html template and show it in the panel.
I have just started with django a week ago and I seriously struggle to understand what goes where.. Following best answer from a Similar problem i do understand that:
class Group(models.Model):
myuser = models.ForeignKey(User, related_name='groups')
goes to my models.py, but i cant really get where would i have to put form.fields['myuser'].queryset = User.objects.filter( groups__name='foo') form.fields['myuser'].queryset = User.objects.filter( groups__name__in=['foo'])
code to... :/
I also have tried another solution (from the same source as above)
qs = User.objects.filter(groups__name__in=['foo'])
to put it in my model.py, such as:
class Group(models.Model):
qs = User.objects.filter(groups__name__in=['Administrators'])
but when i do "makemigrations" i get a lot of errors.
Thank you in advance for understanding
Aucun commentaire:
Enregistrer un commentaire