Instead of this
   def __init__(self, user):
      profile = user.get_profile()

      for g in profile.groups.all():
         self.GROUP_CHOICES += (g.id, g.name)

      super(MyForm, self)

Should it not be,
   def __init__(self, user, *args, **kwargs):
      profile = user.get_profile()

      for g in profile.groups.all():
         self.GROUP_CHOICES += (g.id, g.name)

      super(MyForm, self).__init__(*args, **kwargs)

On Jan 12, 2:18 pm, ocgstyles <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I using the newforms library to create a form.  I need to know who the
> current user is so I know which values to display in a dropdown
> control.  So I have this so far:
>
> from django import newforms as forms
>
> class MyForm(forms.Form):
>     GROUP_CHOICES = []
>
>    field1 = forms.ChoiceField(choices=GROUP_CHOICES)
>    field2 = forms.CharField(widget=forms.Textarea())
>
>    def __init__(self, user):
>       profile = user.get_profile()
>
>       for g in profile.groups.all():
>          self.GROUP_CHOICES += (g.id, g.name)
>
>       super(MyForm, self)
>
> But when I try to render this in the template
> (  {{ form.as_table }} ), I get no output.  Am I creating this form
> class incorrectly?
>
> Keith
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to