I am trying to create a queryset that filters against the logged-in
user's id and the user_id in the record, ie so that only the relevant
user can see the record.
Without the filter, when I display the page I can capture elements in
the template that would allow this comparison, ie:
object.user.id # the record owner
user.id # the logged-in user's id
object.user # the record owner's user name
user # the logged-in user’s user name
So, in models.py I made a new query manager:
class EditManager(models.Manager):
def get_queryset(self):
return super(EditManager, self).get_queryset().filter(
user.id==object.user.id,
expires__gte=datetime.now(timezone.utc),
is_active=True)
Then the debug gives the following error:
Exception Value:name 'user' is not defined
Even if I try fields that are obviously in the table, just to get a
nonsensical filter, I get similar errors, eg "id==user_id".
I have tried variations on the user id comparison, but have not got
any further.
Or, am I going about this completely the wrong way?
Any help greatly appreciated.
-- Clive
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/3F70FF33-445A-4EB4-A582-6C20268B0355%40indx.co.uk.