On Saturday 28 January 2017 21:48:03 Mike08 wrote: > Ok that makes sense. > > Now I have something like this > > class modelStudentAdmin(admin.ModelAdmin): > form = modelStudentAdminForm > > #Only display students that belong to this user > def get_queryset(self, request): > qs = super(modelStudentAdmin, self).get_queryset(request) > > if request.user.is_superuser: > return qs > else: > # Get the school instance > schoolInstance = > modelSchool.objects.get(user=request.user) qs = > modelStudent.objects.filter(school=schoolInstance) return qs > > def get_form(self, request, obj=None, **kwargs):
This self isn't the form. It's the model admin and should return a ModelForm. The docs I linked has a complete example you can build on. -- Melvyn Sopacua -- 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 [email protected]. To post to this group, send email to [email protected]. 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/1530490.zkR37A3afP%40devstation. For more options, visit https://groups.google.com/d/optout.

