On 1 nov, 23:57, Merrick <[EMAIL PROTECTED]> wrote: > I am trying to dynamically generate a form, the fields will vary if > the user is logged in. Here is where I am so far > > forms.py > ====== > class LinkForm(ModelForm): > > def __init__(self, *args, **kw): > self.request = kw.pop('request') > super(LinkForm, self).__init__(*args, **kw) > > class Meta: > model = Link > if self.request.user: > exclude = ['ip_address', 'timestamp', 'user', 'method', ] > else: > exclude = ['ip_address', 'timestamp', 'user', 'method', > 'notes', 'private_stats',]
This is a Python problem, not a Django problem. I strongly suggest you take time to learn Python. <OT> When the 'class Meta:' statement is eval'd, the LinkForm class doesn't even yet exists - so there's no hope an instance of LinkForm could exists. FWIW, there's nothing special with name 'self' in Python. Instance methods receive the current instance as first argument, and by convention, this argument is named 'self', but you could name it 'ekky_ekky_ekky_ekky_zBang' just the same. To make a long story short, what you're trying to do just cannot work - or at least, not that way. </OT> --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---