> On Jul 23, 2015, at 02:47, Déborah Leder <[email protected]> wrote: > > Thanks again for your answer, Josh. > But I still have trouble understanding the get_queryset method... The thing > that bothers me in the code is this : > def get_queryset(self, request): > [...] > qs = super(OwnableAdmin, self).get_queryset(request) > [...] > return [...] > (If you want to see it inside the code, those are the lines 215 and 229 of > OwnableAdmin > <https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/core/admin.py>). > It looks like a vicious circle and I don't understand how this works... Maybe > it is not one because of the “super(OwnableAdmin, self)" that is right > before, but I couldn't find the definition of "super" in this context and > therefore couldn't figure out what is means.
super() is the Python idiom for calling a method on the base class. If you are new to Python but have experience in other object oriented languages then this may sound familiar, and you are just in need of some on-line resources to get up to speed with Python itself. If not, then I would recommend backing up a step or two and work through some Python tutorials. In this case a google search for “python super” seems to give many potentially useful resources. > I just started Python 2-3 weeks ago for django, I still haven't seen all the > concept. Could you explain it to me ? > Also, I understand that request.user is the user that is currently logged in, > but what is the difference between user__id and request.user.id ? (both there > : > https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/core/admin.py#L232 > > <https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/core/admin.py#L232>) user__id is a Django idiom for looking up the field “id” from the object pointed to by the foreign key “user” from the object(s) in the context of the call to objects(). request.user.id is the field “id” in the object “user” found in the request object. You may want to do some reading on the concepts which do not sound familiar. hth - Tom > > > -- > You received this message because you are subscribed to the Google Groups > "Mezzanine Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Mezzanine Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
