On Mar 19, 1:22 pm, Thomas Guettler <h...@tbz-pariv.de> wrote: > Hi, > > I know that you can pass the request object to form like this: > > class MyForm(forms.Form): > def __init__(self, request, *args, **kwargs): > self.request=request > forms.Form.__init__(self, *args, **kwargs) > > Somehow I am tired of rewriting this. Why not store the request > object (in a thread safe way) on module level? > > I recall that someone said this is not good. What are the pro and > contra arguments? > > Most of the time I need request.user to hide some input fields. > > Thomas >
So create a library module and define your own form subclass with that overridden init defined. Now instead of creating a form inheriting from forms.Form, create them based on mylib.RequestForm or whatever you call it. -- DR. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---