Hello,
Is it possible to access request object in 'helpers.py' file ?
Ihave tried 'crequest' (from crequest.middleware import CrequestMiddleware)
without luck.
class AdminField(object):
def __init__(self, form, field, is_first):
self.field = form[field] # A django.forms.BoundField instance
self.is_first = is_first # Whether this field is first on the line
self.is_checkbox = isinstance(self.field.field.widget, forms.CheckboxInput)
if (field == 'albums'):
self.restrictQuery()
def restrictQuery(self):
from portfolio.models import Album
#qs = Album.objects.filter(title='Famille')
qs = Album.objects.all()
self.field.field.queryset = qs
I would like to access 'request.user' in 'restrictQuery
Regards
-- Is it possible to access request object in 'helpers.py' file ?
Ihave tried 'crequest' (from crequest.middleware import CrequestMiddleware)
without luck.
class AdminField(object):
def __init__(self, form, field, is_first):
self.field = form[field] # A django.forms.BoundField instance
self.is_first = is_first # Whether this field is first on the line
self.is_checkbox = isinstance(self.field.field.widget, forms.CheckboxInput)
if (field == 'albums'):
self.restrictQuery()
def restrictQuery(self):
from portfolio.models import Album
#qs = Album.objects.filter(title='Famille')
qs = Album.objects.all()
self.field.field.queryset = qs
I would like to access 'request.user' in 'restrictQuery
Regards
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/73622288-ada3-4555-920c-2d90e8624536%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment