On 16 fév, 20:33, MV <m...@shift.co.nz> wrote: > Hi there, > > I have a question about class variables in Django. If I create a > custom field, e.g. > > class TinyMCEField(models.Field): > superadmin = False > def formfield(self, **kwargs): > if superadmin: > defaults = {'widget':TinyMCE(... blah blah blah})} > else: > defaults = {'widget':TinyMCE(... blah blah blah})}
Actually, this code will raise a NameError on the first line of the formfield function. > And if use middleware to change the value of TinyMCEField.superadmin > to True or False depending on information in request.user, is the > change to the class variable scoped only to that request? Practically, the answer is a very clear "no". > Or am I > doing something dangerous? You are. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---